home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / turttleo.swf / scripts / __Packages / CGame.as next >
Encoding:
Text File  |  2007-10-01  |  106.0 KB  |  2,736 lines

  1. class CGame
  2. {
  3.    var buble_id;
  4.    var redt;
  5.    var _checkpoint_x;
  6.    var _checkpoint_y;
  7.    var _ie;
  8.    var _lvls;
  9.    var _lvls_type;
  10.    var _lvls_rot;
  11.    var _lvls_gfxbg;
  12.    var _lvls_flip;
  13.    var _lvls_tip;
  14.    var _current_map;
  15.    var _map_xml;
  16.    var _levels_xml;
  17.    var last_lvl;
  18.    var _monsters_xml;
  19.    var maxtiles_x;
  20.    var maxtiles_y;
  21.    var _diams;
  22.    var _max_diams;
  23.    var _ready;
  24.    var _tile_size;
  25.    var _tile_sizeh;
  26.    var _game_width;
  27.    var _game_height;
  28.    var _char_x;
  29.    var _char_y;
  30.    var _chp_max;
  31.    var _cmp_max;
  32.    var _chp;
  33.    var _cmp;
  34.    var _cund;
  35.    var _char_alpha;
  36.    var _canim;
  37.    var _csx;
  38.    var _char_xaspeed;
  39.    var _char_xaspeed_max;
  40.    var _csy;
  41.    var _char_ygspeed;
  42.    var _char_run;
  43.    var _char_jump;
  44.    var _scores;
  45.    var _char_lives;
  46.    var _map_x;
  47.    var _map_y;
  48.    var _map_x_max;
  49.    var _exps;
  50.    var _level_start_time;
  51.    var _char_xscale;
  52.    var x;
  53.    var y;
  54.    var _arrowto_x;
  55.    var _arrowto_y;
  56.    static var LEVELS_ID;
  57.    static var _total_monsters_count;
  58.    static var _total_bonuses_count;
  59.    static var MONSTER_ULITKA_SPEED = 1;
  60.    static var MONSTER_FISH3_SPEED = 3;
  61.    static var MONSTER_FISH1_SPEED = 2;
  62.    static var MONSTER_FISH3_KEY = "~";
  63.    static var MONSTER_FISH1_KEY = "_";
  64.    static var MONSTER_FISH1_ZONE_H = 2;
  65.    static var MONSTER_FISH1_ZONE_W = 2;
  66.    static var MONSTER_DEADFALL_YSPEED = -7;
  67.    static var GAME_GRAVITY = 0.8;
  68.    static var TILES_ALL_MONSTERS = "asdu~_";
  69.    static var TILES_ALL_BONUSES = "6789kf2";
  70.    static var IS_LEVEL_EDITOR = false;
  71.    var map_drawed_x = -10000;
  72.    var map_drawed_y = -10000;
  73.    var ELEVATOR_E_SPEED = 2;
  74.    static var ELEVATOR_STATE_WAIT = 0;
  75.    static var ELEVATOR_STATE_GO = 1;
  76.    static var ELEVATOR_STATE_TIMESTOP = 2;
  77.    static var ELEVATOR_STATE_GOBACK = 3;
  78.    static var ELEVATOR_STOP_TIME = 60;
  79.    static var MONSTERS_ID = 1;
  80.    static var ELEVATORS_ID = 2;
  81.    static var TIPS_ID = 3;
  82.    static var COCONUTS_ID = 4;
  83.    var waterlevel_tiley = 0;
  84.    var _stars_collecled = 0;
  85.    static var _level_total_time = 0;
  86.    var _ts = 32;
  87.    var _tsh = 24;
  88.    var _ts2 = 16;
  89.    var _tsh2 = 12;
  90.    var _char_on_elev = false;
  91.    var _char_on_elev_id = 0;
  92.    var _first_turn = 0;
  93.    var TILEW = CGame.prototype._ts;
  94.    var TILEH = CGame.prototype._tsh;
  95.    var DRAW_ZONE_W = 11.5;
  96.    var DRAW_ZONE_H = 13.5;
  97.    var DRAW_ZONE_X0 = -3;
  98.    var DRAW_ZONE_Y0 = -2;
  99.    var _prev_drawed_x = -1;
  100.    var _prev_drawed_y = -1;
  101.    var _prev_drawed_xpix = -1;
  102.    var _prev_drawed_ypix = -1;
  103.    var monsters_to_die = new Array();
  104.    static var COCONUT_STATE_WAIT = 0;
  105.    static var COCONUT_STATE_STRESS = 1;
  106.    static var COCONUT_STATE_FALL = 2;
  107.    static var COCONUT_STATE_LIE = 3;
  108.    static var COCONUT_STATE_FIRE = 4;
  109.    static var COCONUT_STATE_DIE = 5;
  110.    static var COCONUT_FALL_ZONE = 100;
  111.    static var COCONUT_STRESS_TIME = 30;
  112.    static var COCONUT_GRAVITY = CGame.GAME_GRAVITY;
  113.    static var COCONUT_FIRE_X_SPEED = 10;
  114.    static var COCONUT_FIRE_Y_SPEED = -4;
  115.    function CGame(map_xml, cmap, scores, lives, checkpoint_x, checkpoint_y, lvls, diams, stars)
  116.    {
  117.       trace("<CGame>");
  118.       this._stars_collecled = stars;
  119.       this.buble_id = 0;
  120.       _global._game_paused = false;
  121.       this.redt = true;
  122.       if(checkpoint_x == -1 || checkpoint_x == undefined)
  123.       {
  124.          this._checkpoint_x = -1;
  125.          this._checkpoint_y = -1;
  126.       }
  127.       else
  128.       {
  129.          this._checkpoint_x = checkpoint_x;
  130.          this._checkpoint_y = checkpoint_y;
  131.       }
  132.       this._ie = false;
  133.       this._lvls = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  134.       this._lvls_type = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  135.       this._lvls_rot = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  136.       this._lvls_gfxbg = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  137.       this._lvls_flip = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  138.       this._lvls_tip = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
  139.       CGame.LEVELS_ID = 0;
  140.       CGame.MONSTERS_ID = 1;
  141.       CGame.ELEVATORS_ID = 2;
  142.       CGame.TIPS_ID = 3;
  143.       this._current_map = cmap;
  144.       this._map_xml = map_xml;
  145.       this._levels_xml = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.LEVELS_ID];
  146.       if(this._current_map == 4)
  147.       {
  148.          this.last_lvl = true;
  149.       }
  150.       else
  151.       {
  152.          this.last_lvl = false;
  153.       }
  154.       this._monsters_xml = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID];
  155.       this.maxtiles_x = this._levels_xml.childNodes[0].attributes.params.length;
  156.       this.maxtiles_y = this._levels_xml.childNodes.length;
  157.       if(diams == undefined || diams == 0)
  158.       {
  159.          this._diams = 0;
  160.       }
  161.       else
  162.       {
  163.          this._diams = diams;
  164.       }
  165.       if(this._diams >= this._max_diams)
  166.       {
  167.          this._ready = false;
  168.       }
  169.       var _loc11_ = true;
  170.       if(lvls != undefined)
  171.       {
  172.          this._lvls = lvls;
  173.          _loc11_ = false;
  174.       }
  175.       var _loc5_ = 0;
  176.       while(_loc5_ < this.maxtiles_x)
  177.       {
  178.          var _loc4_ = 0;
  179.          while(_loc4_ < this.maxtiles_y)
  180.          {
  181.             this._lvls_gfxbg[_loc5_][_loc4_] = 0;
  182.             if(_loc11_)
  183.             {
  184.                this._lvls[_loc5_][_loc4_] = this._levels_xml.childNodes[_loc4_].attributes.params.charAt(_loc5_);
  185.             }
  186.             _loc4_ = _loc4_ + 1;
  187.          }
  188.          _loc5_ = _loc5_ + 1;
  189.       }
  190.       this._max_diams = 5;
  191.       if(this._diams >= this._max_diams)
  192.       {
  193.          this._ready = true;
  194.       }
  195.       else
  196.       {
  197.          this._ready = false;
  198.       }
  199.       this.set_tiles_angle();
  200.       var _loc13_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.TIPS_ID];
  201.       var _loc7_ = 0;
  202.       while(_loc7_ < _loc13_.childNodes.length)
  203.       {
  204.          var _loc6_ = _loc13_.childNodes[_loc7_];
  205.          var _loc9_ = _loc6_.attributes.xpos;
  206.          var _loc8_ = _loc6_.attributes.ypos;
  207.          var _loc10_ = _loc6_.attributes.tipid;
  208.          this._lvls[_loc9_][_loc8_] = "h";
  209.          this._lvls_tip[_loc9_][_loc8_] = _loc10_;
  210.          _loc7_ = _loc7_ + 1;
  211.       }
  212.       _global._tc = 1;
  213.       this._tile_size = this._ts;
  214.       this._tile_sizeh = this._tsh;
  215.       this._game_width = 400;
  216.       this._game_height = 300;
  217.       this._char_x = 0;
  218.       this._char_y = 0;
  219.       this._chp_max = 7;
  220.       this._cmp_max = 50;
  221.       this._chp = 5;
  222.       this._cmp = this._cmp_max;
  223.       this._cund = 0;
  224.       this._char_alpha = 100;
  225.       this._canim = 1;
  226.       this._csx = 0;
  227.       this._char_xaspeed = 0;
  228.       this._char_xaspeed_max = this._ts * 2 / 3;
  229.       this._csy = 0;
  230.       this._char_ygspeed = (- this._tsh) / 9;
  231.       this._char_run = this._ts / 5;
  232.       this._char_jump = this._ts * 0.95;
  233.       this._scores = 0;
  234.       this._add_scores(scores);
  235.       _root.main.face_scr.cur_scores = scores;
  236.       this._char_lives = lives;
  237.       this._map_x = 0;
  238.       this._map_y = 0;
  239.       this._map_x_max = this.get_x_scr(this.maxtiles_x) - this._game_width - this._ts;
  240.       _root.main.createEmptyMovieClip("gfx_scr",_root.gfx_depth);
  241.       this.show_tiles(0,0);
  242.       this.add_turtle();
  243.       this.show_bg();
  244.       this.add_hp(0);
  245.       _root.main.face_scr.mcDimonds.SetValue(this._diams);
  246.       _root.main.face_scr.lives = this._char_lives;
  247.       this.get_nearest_diam();
  248.       _root.main.face_scr.attachMovie("arrow","arrow_mc",_root.arrow_depth);
  249.       this.show_arrow();
  250.       this._exps = 0;
  251.       _root.anykey_pressed = true;
  252.       _root.anykey_count = 0;
  253.       if(_global.keyboard_control)
  254.       {
  255.          if(Helper.TIPS_BY_EVENT)
  256.          {
  257.             _root.show_tip(8);
  258.          }
  259.       }
  260.       else if(Helper.TIPS_BY_EVENT)
  261.       {
  262.          _root.show_tip(9);
  263.       }
  264.       var _loc12_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID];
  265.       var _loc19_ = _loc12_.childNodes.length;
  266.       while(_loc12_.childNodes.length > 0)
  267.       {
  268.          _loc12_.childNodes[0].removeNode();
  269.       }
  270.       _loc5_ = 0;
  271.       while(_loc5_ < this.maxtiles_x)
  272.       {
  273.          _loc4_ = 0;
  274.          while(_loc4_ < this.maxtiles_y)
  275.          {
  276.             if(this._lvls[_loc5_][_loc4_] == "E")
  277.             {
  278.                this._lvls[_loc5_][_loc4_] = "e";
  279.             }
  280.             else if(this._lvls[_loc5_][_loc4_] == "O")
  281.             {
  282.                this._lvls[_loc5_][_loc4_] = "o";
  283.             }
  284.             else if(this._lvls[_loc5_][_loc4_] == "T")
  285.             {
  286.                this._lvls[_loc5_][_loc4_] = "t";
  287.             }
  288.             _loc4_ = _loc4_ + 1;
  289.          }
  290.          _loc5_ = _loc5_ + 1;
  291.       }
  292.       var _loc15_ = this._checkpoint_x == -1;
  293.       if(_loc15_)
  294.       {
  295.          CGame._total_monsters_count = this.GetCountTilesOfType(CGame.TILES_ALL_MONSTERS,this._lvls);
  296.          CGame._total_bonuses_count = this.GetCountTilesOfType(CGame.TILES_ALL_BONUSES,this._lvls);
  297.          CGame._level_total_time = 0;
  298.       }
  299.       this._level_start_time = getTimer();
  300.       this.waterlevel_tiley = Math.round(Number(XMLNode(this._map_xml.firstChild.childNodes[this._current_map]).attributes.waterlevel));
  301.       this.waterlevel_tiley *= this._tsh;
  302.       this.UpdateWaterLevel();
  303.       this.generate_gfxbg();
  304.       trace("</CGame>");
  305.    }
  306.    function GetCountTilesOfType(types, search_in_array)
  307.    {
  308.       var _loc4_ = 0;
  309.       var _loc3_ = 0;
  310.       while(_loc3_ < this.maxtiles_x)
  311.       {
  312.          var _loc2_ = 0;
  313.          while(_loc2_ < this.maxtiles_y)
  314.          {
  315.             if(types.indexOf(search_in_array[_loc3_][_loc2_]) != -1)
  316.             {
  317.                _loc4_ = _loc4_ + 1;
  318.             }
  319.             _loc2_ = _loc2_ + 1;
  320.          }
  321.          _loc3_ = _loc3_ + 1;
  322.       }
  323.       return _loc4_;
  324.    }
  325.    function kick_char(side)
  326.    {
  327.       _root.hero_dmg.start();
  328.       _root.main.char._alpha = 40;
  329.       this._cund = 60;
  330.       this._csy = this._char_jump * 0.5;
  331.       this._char_xaspeed -= this._char_run * 3 * side;
  332.       this._canim = 3;
  333.    }
  334.    function move_char(to_x, to_y)
  335.    {
  336.       var _loc3_ = 40;
  337.       var _loc2_ = 0;
  338.       if(to_x - _loc3_ > this._char_x)
  339.       {
  340.          _loc2_ = 1;
  341.       }
  342.       if(to_x + _loc3_ < this._char_x)
  343.       {
  344.          _loc2_ = -1;
  345.       }
  346.       this.move(_loc2_);
  347.    }
  348.    function move(side)
  349.    {
  350.       _root.anykey_count = 0;
  351.       _root.anykey_pressed = true;
  352.       this._csx = side;
  353.       if(this._canim != 3)
  354.       {
  355.          this._canim = 2;
  356.       }
  357.       if(side != 0)
  358.       {
  359.          _root.main.char._xscale = this._char_xscale * side;
  360.       }
  361.    }
  362.    function jump_char()
  363.    {
  364.       var _loc3_ = Math.round((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
  365.       var _loc2_ = Math.round((this._char_y + this._map_y + this._tsh2) / this._tsh);
  366.       if((this._levels_xml.childNodes[_loc2_ - 1].attributes.params.charAt(_loc3_) == 0 || this._char_on_elev) && this._csy == 0)
  367.       {
  368.          this._jump_char();
  369.       }
  370.    }
  371.    function _jump_from_mon_char()
  372.    {
  373.       _root.anykey_pressed = true;
  374.       _root.hero_mon.start();
  375.       this._csy = this._char_jump;
  376.       this._canim = 3;
  377.    }
  378.    function _jump_char()
  379.    {
  380.       _root.anykey_count = 0;
  381.       _root.anykey_pressed = true;
  382.       _root.hero_jump.start();
  383.       this._csy += this._char_jump;
  384.       this._canim = 3;
  385.    }
  386.    function TestMonsterWithChar(monst_mc, charx, chary)
  387.    {
  388.       return monst_mc.hitTest(charx,chary,true) || monst_mc.hitTest(charx,chary - this._tsh,true);
  389.    }
  390.    function turn()
  391.    {
  392.       if(this._first_turn > 5 && this._first_turn < 7)
  393.       {
  394.          _root.main.face_scr.mcShells.SetValue(this._chp);
  395.          this._first_turn = this._first_turn + 1;
  396.       }
  397.       else if(this._first_turn < 7)
  398.       {
  399.          this._first_turn = this._first_turn + 1;
  400.       }
  401.       if(_global._tc > 30)
  402.       {
  403.          _global._tc = 1;
  404.       }
  405.       else
  406.       {
  407.          _global._tc = _global._tc + 1;
  408.       }
  409.       var _loc16_ = Math.round;
  410.       var _loc6_ = _loc16_((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
  411.       var _loc7_ = _loc16_((this._char_y + this._map_y + this._tsh2) / this._tsh);
  412.       var _loc45_ = this._lvls[_loc6_][_loc7_];
  413.       var _loc30_ = false;
  414.       var _loc27_ = _root.main.gfx_scr.monsters_scr;
  415.       if((this.TestMonsterWithChar(_loc27_,_root.main.char._x + 5,_root.main.char._y) || this.TestMonsterWithChar(_loc27_,_root.main.char._x - 5,_root.main.char._y)) && this._csy < -0.5)
  416.       {
  417.          trace("_csy==" + this._csy);
  418.          this._jump_from_mon_char();
  419.          var _loc17_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
  420.          var _loc10_ = 0;
  421.          while(_loc10_ < _loc17_)
  422.          {
  423.             if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes.type != "s")
  424.             {
  425.                if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes.type != "d")
  426.                {
  427.                   var _loc8_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc10_].attributes;
  428.                   var _loc26_ = "monster" + _loc10_;
  429.                   var _loc13_ = _loc27_[_loc26_];
  430.                   if(this.TestMonsterWithChar(_loc13_,_root.main.char._x + 5,_root.main.char._y) || this.TestMonsterWithChar(_loc13_,_root.main.char._x - 5,_root.main.char._y))
  431.                   {
  432.                      this.add_explosion(_loc13_._x,_loc13_._y,2);
  433.                      var _loc20_ = Math.random();
  434.                      if(_loc20_ >= 0.7)
  435.                      {
  436.                         if(this._lvls[_loc6_][_loc7_ - 1] == 1)
  437.                         {
  438.                            var _loc18_ = 3;
  439.                            if(Math.random() > 0.5)
  440.                            {
  441.                               _loc18_ = 4;
  442.                            }
  443.                            this._lvls[_loc6_][_loc7_ - 1] = _loc18_;
  444.                         }
  445.                         this.redt = true;
  446.                      }
  447.                      if(_loc8_.type == "u")
  448.                      {
  449.                         _root.snd_snain_die.start();
  450.                      }
  451.                      else if(_loc8_.type == CGame.MONSTER_FISH3_KEY)
  452.                      {
  453.                         _root.snd_fish3_die.start();
  454.                      }
  455.                      else if(_loc8_.type == CGame.MONSTER_FISH1_KEY)
  456.                      {
  457.                         _root.snd_fish1_die.start();
  458.                      }
  459.                      else if(_loc8_.type == "a")
  460.                      {
  461.                         _root.snd_octopus_die.start();
  462.                      }
  463.                      this.kill_monster(_loc10_);
  464.                      _loc30_ = true;
  465.                   }
  466.                }
  467.             }
  468.             _loc10_ = _loc10_ + 1;
  469.          }
  470.       }
  471.       if(this._cund == 0 && !_loc30_)
  472.       {
  473.          if(this.TestMonsterWithChar(_loc27_,_root.main.char._x + 5,_root.main.char._y))
  474.          {
  475.             this.add_hp(-1);
  476.             this.kick_char(1);
  477.          }
  478.          else if(this.TestMonsterWithChar(_loc27_,_root.main.char._x - 5,_root.main.char._y))
  479.          {
  480.             this.add_hp(-1);
  481.             this.kick_char(-1);
  482.          }
  483.       }
  484.       if(_root.main.gfx_scr.coconuts_scr.hitTest(_root.main.char._x,_root.main.char._y,true))
  485.       {
  486.          trace(111);
  487.          var _loc33_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
  488.          _loc10_ = 0;
  489.          while(_loc10_ < _loc33_)
  490.          {
  491.             trace("222 " + _loc10_);
  492.             _loc26_ = "coconut" + _loc10_;
  493.             trace(_root.main.char._x);
  494.             if(_root.main.gfx_scr.coconuts_scr[_loc26_].hitTest(_root.main.char._x,_root.main.char._y,true))
  495.             {
  496.                trace("333 " + _loc10_);
  497.                var _loc19_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc10_].attributes;
  498.                if(_loc19_.state == CGame.COCONUT_STATE_LIE && this._csy == 0)
  499.                {
  500.                   trace("coconut FIRE");
  501.                   _loc19_.state = CGame.COCONUT_STATE_FIRE;
  502.                   _loc19_.xspeed = CGame.COCONUT_FIRE_X_SPEED * (this._csx < 0 ? -1 : 1);
  503.                   _loc19_.yspeed = CGame.COCONUT_FIRE_Y_SPEED;
  504.                }
  505.                else if(_loc19_.state == CGame.COCONUT_STATE_FALL)
  506.                {
  507.                   this.add_hp(-1);
  508.                   this.kick_char(_loc19_.xspeed <= 0 ? 1 : -1);
  509.                }
  510.                break;
  511.             }
  512.             _loc10_ = _loc10_ + 1;
  513.          }
  514.       }
  515.       _loc33_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
  516.       _loc10_ = 0;
  517.       while(_loc10_ < _loc33_)
  518.       {
  519.          _loc26_ = "coconut" + _loc10_;
  520.          _loc19_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc10_].attributes;
  521.          if(!(_loc19_.state != CGame.COCONUT_STATE_FIRE && _loc19_.state != CGame.COCONUT_STATE_FALL))
  522.          {
  523.             var _loc9_ = new Object();
  524.             _loc9_.x = _root.main.gfx_scr.coconuts_scr[_loc26_]._x;
  525.             _loc9_.y = _root.main.gfx_scr.coconuts_scr[_loc26_]._y;
  526.             _root.main.gfx_scr.localToGlobal(_loc9_);
  527.             var _loc15_ = _loc9_.x;
  528.             var _loc14_ = _loc9_.y;
  529.             if(_root.main.gfx_scr.monsters_scr.hitTest(_loc15_,_loc14_,true))
  530.             {
  531.                _loc17_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
  532.                var _loc4_ = 0;
  533.                while(_loc4_ < _loc17_)
  534.                {
  535.                   var _loc12_ = "monster" + _loc4_;
  536.                   if(_root.main.gfx_scr.monsters_scr[_loc12_].hitTest(_loc15_,_loc14_,true))
  537.                   {
  538.                      var _loc5_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc4_].attributes.type;
  539.                      if(_loc5_ == "u")
  540.                      {
  541.                         _root.snd_snain_die.start();
  542.                      }
  543.                      else if(_loc5_ == CGame.MONSTER_FISH3_KEY)
  544.                      {
  545.                         _root.snd_fish3_die.start();
  546.                      }
  547.                      else if(_loc5_ == CGame.MONSTER_FISH1_KEY)
  548.                      {
  549.                         _root.snd_fish1_die.start();
  550.                      }
  551.                      else if(_loc8_.type == "a")
  552.                      {
  553.                         _root.snd_octopus_die.start();
  554.                      }
  555.                      this.kill_monster(_loc4_);
  556.                   }
  557.                   _loc4_ = _loc4_ + 1;
  558.                }
  559.             }
  560.          }
  561.          _loc10_ = _loc10_ + 1;
  562.       }
  563.       if(_loc45_ == "v")
  564.       {
  565.          _root.savepoint.start();
  566.          this._checkpoint_x = _loc6_;
  567.          this._checkpoint_y = _loc7_;
  568.          this._lvls[_loc6_][_loc7_] = "b";
  569.          this.redt = true;
  570.       }
  571.       if(this._csy < 0)
  572.       {
  573.          if(this._lvls[_loc6_][_loc7_ - 1] == "x")
  574.          {
  575.             this._jump_char();
  576.             this._jump_char();
  577.             this._lvls[_loc6_][_loc7_ - 1] = 1;
  578.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  579.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  580.             this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
  581.             this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
  582.             this.redt = true;
  583.          }
  584.          if(this._lvls[_loc6_ - 1][_loc7_ - 1] == "x")
  585.          {
  586.             this._jump_char();
  587.             this._jump_char();
  588.             this._lvls[_loc6_ - 1][_loc7_ - 1] = 1;
  589.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  590.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  591.             this.add_explosion(this.get_x_scr(_loc6_ - 1),this.get_y_scr(_loc7_ - 1),2);
  592.             this.add_explosion(this.get_x_scr(_loc6_ - 1),this.get_y_scr(_loc7_ - 1),2);
  593.             this.redt = true;
  594.          }
  595.          if(this._lvls[_loc6_][_loc7_ - 1] == "m")
  596.          {
  597.             this._jump_char();
  598.             this._jump_char();
  599.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  600.             this.add_explosion(this.get_x_scr(_loc6_),this.get_y_scr(_loc7_ - 1),2);
  601.             this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
  602.             this.add_explosion(this.get_x_scr(_loc6_ + 1),this.get_y_scr(_loc7_ - 1),2);
  603.          }
  604.       }
  605.       this.elevators_move();
  606.       var _loc11_ = 0;
  607.       var _loc35_ = _loc16_((this._char_x + (this._csx + this._char_xaspeed) * this._ts2 + this._map_x + this._ts2) / this._ts) - 1;
  608.       if(!(this._lvls[_loc35_][_loc7_] == 0 && this._lvls[_loc35_][_loc7_ + 1] == 0 || this._lvls[_loc35_][_loc7_] == 0 && this._lvls[_loc35_][_loc7_ - 1] == 0 || this._lvls[_loc35_][_loc7_] == undefined))
  609.       {
  610.          _loc11_ = this._csx * this._char_run + this._char_xaspeed;
  611.       }
  612.       var _loc42_ = 0;
  613.       var _loc38_ = 0;
  614.       if(this._csy < 0 && !this._char_on_elev)
  615.       {
  616.          var _loc31_ = this._char_y + this._csy;
  617.          var _loc32_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
  618.          var _loc24_ = false;
  619.          _loc10_ = 0;
  620.          while(_loc10_ < _loc32_)
  621.          {
  622.             _loc26_ = "elevator" + _loc10_;
  623.             var _loc28_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc10_];
  624.             var _loc44_ = _loc28_.attributes.x - this._map_x;
  625.             var _loc46_ = this._game_height - _loc28_.attributes.y - this._map_y + this._tsh2;
  626.             var _loc43_ = _loc28_.attributes.wide2;
  627.             var _loc40_ = Math.abs(_loc28_.attributes.speed) + 2;
  628.             if(this._char_x >= _loc44_ - _loc43_ && this._char_x <= _loc44_ + _loc43_ && this._char_y > _loc46_ && _loc31_ - _loc40_ <= _loc46_)
  629.             {
  630.                this._char_on_elev = true;
  631.                this._char_on_elev_id = _loc10_;
  632.                this._char_y = _loc46_;
  633.                this._csy = 0;
  634.                _loc24_ = true;
  635.                break;
  636.             }
  637.             if(!_loc24_)
  638.             {
  639.                this._char_on_elev = false;
  640.             }
  641.             _loc10_ = _loc10_ + 1;
  642.          }
  643.       }
  644.       else if(this._char_on_elev)
  645.       {
  646.          _loc28_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[this._char_on_elev_id];
  647.          _loc44_ = _loc28_.attributes.x - this._map_x;
  648.          _loc46_ = this._game_height - _loc28_.attributes.y - this._map_y + this._tsh2;
  649.          _loc43_ = _loc28_.attributes.wide2;
  650.          var _loc39_ = _loc28_.attributes.side;
  651.          _loc40_ = _loc28_.attributes.speed;
  652.          if(this._char_x < _loc44_ - _loc43_ || this._char_x > _loc44_ + _loc43_)
  653.          {
  654.             this._char_on_elev = false;
  655.          }
  656.          if(this._char_on_elev)
  657.          {
  658.             this._char_y = _loc46_;
  659.             if(_loc28_.attributes.type == "o")
  660.             {
  661.                this._char_x += _loc40_ * (- _loc39_);
  662.                _loc38_ = _loc40_ * (- _loc39_);
  663.             }
  664.             else if(_loc28_.attributes.type == "e")
  665.             {
  666.                _loc42_ = _loc40_ * _loc39_;
  667.             }
  668.             else if(_loc28_.attributes.type == "t")
  669.             {
  670.                switch(_loc28_.attributes.state)
  671.                {
  672.                   case CGame.ELEVATOR_STATE_GO:
  673.                   case CGame.ELEVATOR_STATE_GOBACK:
  674.                      _loc42_ = _loc40_ * _loc39_;
  675.                }
  676.             }
  677.          }
  678.       }
  679.       var _loc41_ = this._csy;
  680.       if(!this._char_on_elev)
  681.       {
  682.          if(this._lvls[_loc6_][_loc7_ - 1] != 0 || this._lvls[_loc6_][_loc7_ - 1] == 0 && this._csy > 0)
  683.          {
  684.             this._csy += this._char_ygspeed;
  685.             _loc41_ = this._csy;
  686.          }
  687.          else if(this._csy <= 0)
  688.          {
  689.             if(Math.abs(_loc11_) > 0.2)
  690.             {
  691.                this._canim = 2;
  692.             }
  693.             else
  694.             {
  695.                this._canim = 1;
  696.             }
  697.             if(this._csy < 0)
  698.             {
  699.                this._csy = 0;
  700.             }
  701.          }
  702.       }
  703.       else if(this._csy > 0)
  704.       {
  705.          this._csy += this._char_ygspeed;
  706.          _loc41_ = this._csy;
  707.          this._char_on_elev = false;
  708.       }
  709.       if(this._char_on_elev)
  710.       {
  711.          if(Math.abs(_loc11_) > 0.2)
  712.          {
  713.             this._canim = 2;
  714.          }
  715.          else
  716.          {
  717.             this._canim = 1;
  718.          }
  719.       }
  720.       if(!this._char_on_elev)
  721.       {
  722.          var _loc21_ = _loc16_((this._char_y + this._map_y + this._tsh2 + 2) / this._tsh);
  723.          if(this._lvls[_loc6_][_loc21_ - 1] == 0 && this._csy == 0)
  724.          {
  725.             var _loc23_ = 0;
  726.             var _loc25_ = 0;
  727.             var _loc22_ = 0;
  728.             var _loc36_ = undefined;
  729.             var _loc34_ = undefined;
  730.             var _loc29_ = 0;
  731.             while(this._lvls[_loc6_][_loc21_ - 1] == 0)
  732.             {
  733.                _loc29_ = 1;
  734.                _loc22_ = _loc22_ + 1;
  735.                _loc23_ -= _loc11_ / 3;
  736.                _loc25_ += _loc11_ / 3;
  737.                _loc21_ = _loc16_((this._char_y + _loc22_ + this._map_y + 2 + this._tsh2) / this._tsh);
  738.                _loc36_ = _loc16_((this._char_x + _loc23_ + this._map_x + this._ts2) / this._ts) - 1;
  739.                _loc34_ = _loc16_((this._char_x + _loc25_ + this._map_x + this._ts2) / this._ts) - 1;
  740.             }
  741.             switch(_loc29_)
  742.             {
  743.                case 0:
  744.                   this._char_x += _loc23_ * 2;
  745.                   this._char_xaspeed = (- this._char_run) * 2;
  746.                   this._csy = _loc41_;
  747.                   _loc11_ = 0;
  748.                   _loc6_ = _loc16_((this._char_x + this._map_x + this._ts2) / this._ts) - 1;
  749.                   break;
  750.                case 1:
  751.                   this._char_y += _loc22_;
  752.                   _root.hero_step.start();
  753.                   _loc7_ = _loc16_((this._char_y + this._map_y + this._tsh2) / this._tsh);
  754.             }
  755.          }
  756.       }
  757.       if(this._lvls[_loc6_][_loc7_ + 1] == 0 && this._lvls[_loc6_][_loc7_ + 2] == 0)
  758.       {
  759.          if(this._csy > 0)
  760.          {
  761.             this._csy = 0;
  762.          }
  763.       }
  764.       if(Math.abs(this._char_xaspeed) < 4)
  765.       {
  766.          this._char_xaspeed = 0;
  767.       }
  768.       else
  769.       {
  770.          this._char_xaspeed *= 0.86;
  771.       }
  772.       if(_loc11_ > this._char_run)
  773.       {
  774.          _loc11_ = this._char_run;
  775.       }
  776.       if(_loc11_ < - this._char_run)
  777.       {
  778.          _loc11_ = - this._char_run;
  779.       }
  780.       if(_loc7_ < 0)
  781.       {
  782.          _root.hero_fall.start();
  783.          this.lose_game(0);
  784.          return true;
  785.       }
  786.       if(this._lvls[_loc6_][_loc7_ + 1] > 1)
  787.       {
  788.          this.add_scores(_loc6_,_loc7_ + 1);
  789.          this.redt = true;
  790.       }
  791.       if(this._lvls[_loc6_][_loc7_] > 1)
  792.       {
  793.          this.add_scores(_loc6_,_loc7_);
  794.          this.redt = true;
  795.       }
  796.       if(this._lvls[_loc6_][_loc7_] == "z")
  797.       {
  798.          if(Helper.TIPS_BY_EVENT)
  799.          {
  800.             _root.show_tip(5);
  801.          }
  802.          if(this._ready)
  803.          {
  804.             if(this.last_lvl)
  805.             {
  806.                this.OpenWinnerWindow();
  807.             }
  808.             else
  809.             {
  810.                this.OpenWinnerWindow();
  811.             }
  812.             return true;
  813.          }
  814.       }
  815.       if(_loc45_ == "h")
  816.       {
  817.          if(this._lvls_tip[_loc6_][_loc7_] != undefined)
  818.          {
  819.             trace("show_tip: " + this._lvls_tip[_loc6_][_loc7_]);
  820.             if(_root.show_tip(this._lvls_tip[_loc6_][_loc7_]))
  821.             {
  822.                if(this._canim == 2)
  823.                {
  824.                   this._canim = 1;
  825.                }
  826.             }
  827.          }
  828.          this._lvls[_loc6_][_loc7_] = "H";
  829.          this.redt = true;
  830.       }
  831.       if(this._char_x > 220 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 140 && _loc11_ < 0 && this._map_x >= 0)
  832.       {
  833.          this._map_x += _loc11_;
  834.          this.move_bg(_loc11_);
  835.          this.redt = true;
  836.       }
  837.       else if(this._char_x > 200 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 160 && _loc11_ < 0 && this._map_x >= 0)
  838.       {
  839.          this._char_x += _loc11_ * 0.33;
  840.          this._map_x += _loc11_ * 0.66;
  841.          this.move_bg(_loc11_ * 0.66);
  842.          this.redt = true;
  843.       }
  844.       else if(this._char_x > 180 && _loc11_ > 0 && this._map_x <= this._map_x_max || this._char_x < 180 && _loc11_ < 0 && this._map_x >= 0)
  845.       {
  846.          _loc11_ /= 2;
  847.          this._char_x += _loc11_;
  848.          this._map_x += _loc11_;
  849.          this.move_bg(_loc11_);
  850.          this.redt = true;
  851.       }
  852.       else if(this._char_on_elev && _loc38_ != 0 && (this._char_x > 200 || this._char_x < 160))
  853.       {
  854.          this._char_x += _loc11_ - _loc38_;
  855.          this._map_x += _loc38_;
  856.          this.move_bg(_loc38_);
  857.          this.redt = true;
  858.       }
  859.       else
  860.       {
  861.          this._char_x += _loc11_;
  862.       }
  863.       if(Math.abs(this._csy) < 0.2)
  864.       {
  865.          this._csy = 0;
  866.       }
  867.       else
  868.       {
  869.          this._csy *= 0.92;
  870.       }
  871.       var _loc37_ = !!this._char_on_elev ? - _loc42_ : this._csy;
  872.       if(this._char_y > 180 && (this._csy > 0 || this._char_on_elev) || this._char_y < 100 && (this._csy < 0 || this._char_on_elev) && this._map_y > 0)
  873.       {
  874.          this._map_y += _loc37_;
  875.          this.redt = true;
  876.       }
  877.       else if(this._char_y > 150 && (this._csy > 0 || this._char_on_elev) || this._char_y < 150 && (this._csy < 0 || this._char_on_elev) && this._map_y > 0)
  878.       {
  879.          _loc37_ /= 2;
  880.          this._map_y += _loc37_;
  881.          this._char_y += _loc37_;
  882.          this.redt = true;
  883.       }
  884.       else
  885.       {
  886.          this._char_y += _loc37_;
  887.       }
  888.       if(this._map_y < 0)
  889.       {
  890.          this._map_y = 0;
  891.       }
  892.       if(this.redt)
  893.       {
  894.          this.show_tiles();
  895.          this.redt = false;
  896.       }
  897.       _root.main.char._x = this._char_x;
  898.       _root.main.char._y = this._game_height - this._char_y;
  899.       _root.main.char.gotoAndStop(this._canim);
  900.       _root.main.gfx_scr._x = - this._map_x;
  901.       _root.main.gfx_scr._y = this._map_y;
  902.       this.monsters_move();
  903.       this.coconuts_move();
  904.       this.UpdateWaterLevel();
  905.       this.show_arrow();
  906.       if(this._cund > 0)
  907.       {
  908.          this._cund = this._cund - 1;
  909.          if(this._char_alpha < 100)
  910.          {
  911.             this._char_alpha = 100;
  912.          }
  913.          else
  914.          {
  915.             this._char_alpha = 30;
  916.          }
  917.          _root.main.char._alpha = this._char_alpha;
  918.       }
  919.    }
  920.    function add_scores(x, y)
  921.    {
  922.       var _loc3_ = Number(this._lvls[x][y] / 1);
  923.       switch(_loc3_)
  924.       {
  925.          case 2:
  926.             _root.pick_hp.start();
  927.             this._char_lives = this._char_lives + 1;
  928.             _root.main.face_scr.lives = this._char_lives;
  929.             break;
  930.          case 3:
  931.             _root.pick_hp.start();
  932.             this._add_hp();
  933.             break;
  934.          case 4:
  935.             break;
  936.          case 5:
  937.             _root.pick_diam.start();
  938.             this._add_diam();
  939.             break;
  940.          case 6:
  941.             _root.pick_gsmall.start();
  942.             this._add_scores(10);
  943.             break;
  944.          case 7:
  945.             _root.pick_gbig.start();
  946.             this._add_scores(50);
  947.             break;
  948.          case 8:
  949.             _root.pick_gbig.start();
  950.             this._add_scores(100);
  951.             break;
  952.          case 9:
  953.             _root.pick_gbig.start();
  954.             this._add_scores(300);
  955.             break;
  956.          case 11:
  957.             _root.pick_gbig.start();
  958.             this._add_scores(500);
  959.             break;
  960.          case 12:
  961.             _root.pick_gbig.start();
  962.             this._add_scores(1000);
  963.             this._stars_collecled = this._stars_collecled + 1;
  964.             break;
  965.          default:
  966.             trace("Get UNKNOWN bonus: " + _loc3_);
  967.       }
  968.       this.add_explosion(this.get_x_scr(x),this.get_y_scr(y),1);
  969.       this._lvls[x][y] = 1;
  970.       this.get_nearest_diam();
  971.    }
  972.    function _add_mp()
  973.    {
  974.       this.add_mp(this._cmp_max * 0.5);
  975.    }
  976.    function _add_hp()
  977.    {
  978.       this.add_hp(1);
  979.    }
  980.    function _add_diam()
  981.    {
  982.       if(this._diams == 0 && this._current_map == 0)
  983.       {
  984.          if(Helper.TIPS_BY_EVENT)
  985.          {
  986.             _root.show_tip(1);
  987.          }
  988.       }
  989.       if(this._diams == 2 && this._current_map == 0)
  990.       {
  991.          if(Helper.TIPS_BY_EVENT)
  992.          {
  993.             _root.show_tip(2);
  994.          }
  995.       }
  996.       this._diams = this._diams + 1;
  997.       this.redt = true;
  998.       _root.main.face_scr.diamshine_mc.play();
  999.       if(this._diams >= this._max_diams && !this._ready)
  1000.       {
  1001.          _root.main.face_scr.win_scr._visible = true;
  1002.          _root.main.face_scr.attachMovie("win_txt","win_txt",_root.win_depth,{_x:40,_y:60});
  1003.          this._ready = true;
  1004.       }
  1005.       _root.main.face_scr.mcDimonds.SetValue(this._diams);
  1006.    }
  1007.    function _add_scores(scores)
  1008.    {
  1009.       if(this._scores > 0)
  1010.       {
  1011.          if(Helper.TIPS_BY_EVENT)
  1012.          {
  1013.             _root.show_tip(0);
  1014.          }
  1015.       }
  1016.       this._scores += scores;
  1017.       _level0.swHighScoreObject.player1Score = this._scores;
  1018.       _root.main.face_scr.scores = this._scores;
  1019.       _root.main.face_scr.moneyshine_mc.play();
  1020.    }
  1021.    function get_x_scr(x)
  1022.    {
  1023.       return x * this._ts + this._ts2;
  1024.    }
  1025.    function get_y_scr(y)
  1026.    {
  1027.       return this._game_height - (y * this._tsh + this._tsh2);
  1028.    }
  1029.    function move_bg(step)
  1030.    {
  1031.    }
  1032.    function show_bg()
  1033.    {
  1034.       _root.main.createEmptyMovieClip("bg_scr",_root.bg_depth);
  1035.       _root.main.bg_scr.attachMovie("bg_scr","bg_scr",_root.bg_depth + 1);
  1036.    }
  1037.    function show_tiles()
  1038.    {
  1039.       var _loc33_ = this.DRAW_ZONE_W - this.DRAW_ZONE_X0;
  1040.       var _loc34_ = this.DRAW_ZONE_H - this.DRAW_ZONE_Y0;
  1041.       var _loc4_ = 0;
  1042.       var _loc5_ = "";
  1043.       var _loc7_ = undefined;
  1044.       var _loc29_ = Math.round(this._map_x / this.TILEW);
  1045.       var _loc28_ = Math.round(this._map_y / this.TILEH);
  1046.       var _loc36_ = true;
  1047.       var _loc22_ = true;
  1048.       if(this._prev_drawed_x == _loc29_ && this._prev_drawed_y == _loc28_)
  1049.       {
  1050.          var _loc31_ = this.get_x_scr(this._prev_drawed_x) - this._map_x;
  1051.          var _loc30_ = this.get_y_scr(this._prev_drawed_y) - this._map_y;
  1052.          var _loc12_ = _loc31_ - this._prev_drawed_xpix;
  1053.          var _loc32_ = _loc30_ - this._prev_drawed_ypix;
  1054.          _root.main.ts_mc_static._x += _loc12_;
  1055.          _root.main.ts_mc_static._y -= _loc32_;
  1056.          this._prev_drawed_xpix = _loc31_;
  1057.          this._prev_drawed_ypix = _loc30_;
  1058.          _loc22_ = false;
  1059.       }
  1060.       else
  1061.       {
  1062.          this._prev_drawed_x = _loc29_;
  1063.          this._prev_drawed_y = _loc28_;
  1064.          this._prev_drawed_xpix = this.get_x_scr(this._prev_drawed_x) - this._map_x;
  1065.          this._prev_drawed_ypix = this.get_y_scr(this._prev_drawed_y) - this._map_y;
  1066.          _root.main.createEmptyMovieClip("ts_mc_static",-600);
  1067.       }
  1068.       var _loc23_ = _root.main.ts_mc_static;
  1069.       var _loc6_ = _root.main.createEmptyMovieClip("ts_mc",-300);
  1070.       var _loc35_ = _root.main.createEmptyMovieClip("ts2_mc",8000);
  1071.       var x;
  1072.       var y;
  1073.       var _loc26_ = this.DRAW_ZONE_Y0 + _loc28_;
  1074.       var _loc25_ = this.DRAW_ZONE_X0 + _loc29_;
  1075.       var _loc27_ = _loc34_ + _loc28_;
  1076.       var _loc24_ = _loc33_ + _loc29_;
  1077.       y = _loc26_;
  1078.       while(y < _loc27_)
  1079.       {
  1080.          x = _loc25_;
  1081.          for(; x < _loc24_; x++)
  1082.          {
  1083.             var _loc9_ = this._lvls[x][y];
  1084.             var _loc8_ = this._lvls_gfxbg[x][y];
  1085.             if(_loc8_[0] != 0)
  1086.             {
  1087.                _loc4_ = _loc4_ + 1;
  1088.                _loc5_ = "tiles" + _loc4_;
  1089.                var _loc13_ = _loc8_[1];
  1090.                _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + _loc8_[3],_xscale:_loc8_[1],_yscale:_loc13_});
  1091.                if(_loc8_[2] != 2)
  1092.                {
  1093.                   _loc6_.attachMovie("tiles_decor" + _loc8_[0],_loc5_,_root["decor_depth" + _loc8_[2]] / 1 + _loc4_,_loc7_);
  1094.                }
  1095.                else
  1096.                {
  1097.                   _root.main.ts2_mc.attachMovie("tiles_decor" + _loc8_[0],_loc5_,_root["decor_depth" + _loc8_[2]] / 1 + _loc4_,_loc7_);
  1098.                }
  1099.             }
  1100.             var _loc11_ = _loc9_ / 1 + 1;
  1101.             if(_loc22_ && this._lvls_type[x][y] != 0)
  1102.             {
  1103.                _loc4_ = _loc4_ + 1;
  1104.                _loc5_ = "tiles" + _loc4_;
  1105.                var _loc15_ = Math.floor(this.get_x_scr(x) - this._map_x);
  1106.                var _loc14_ = Math.floor(this.get_y_scr(y) + this._map_y);
  1107.                _loc7_ = new Object({_x:_loc15_,_y:_loc14_});
  1108.                var _loc10_ = _loc23_.attachMovie("tiles_ground" + this._lvls_type[x][y],_loc5_,_root.tiles_depth + _loc4_,_loc7_);
  1109.                if(this._lvls_rot[x][y] > 0)
  1110.                {
  1111.                   _loc10_._rotation -= 90 * this._lvls_rot[x][y];
  1112.                }
  1113.                if(this._lvls_flip[x][y] > 0)
  1114.                {
  1115.                   if(this._lvls_flip[x][y] == 1)
  1116.                   {
  1117.                      _loc10_._xscale = -100;
  1118.                   }
  1119.                   else if(this._lvls_flip[x][y] == 2)
  1120.                   {
  1121.                      _loc10_._yscale = -100;
  1122.                   }
  1123.                }
  1124.                continue;
  1125.             }
  1126.             if(_loc9_ == undefined || _loc9_ == 1)
  1127.             {
  1128.                continue;
  1129.             }
  1130.             switch(_loc9_)
  1131.             {
  1132.                case "e":
  1133.                   this.add_elevator("e",x,y,_loc4_);
  1134.                   break;
  1135.                case "t":
  1136.                   this.add_elevator("t",x,y,_loc4_);
  1137.                   break;
  1138.                case "o":
  1139.                   this.add_elevator("o",x,y,_loc4_);
  1140.                   break;
  1141.                case "r":
  1142.                case "p":
  1143.                case "y":
  1144.                case "E":
  1145.                case "T":
  1146.                case "O":
  1147.                   if(Helper.DEBUG_MAP)
  1148.                   {
  1149.                      _loc4_ = _loc4_ + 1;
  1150.                      _loc5_ = "tiles" + _loc4_;
  1151.                      _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1152.                      _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1153.                      _loc6_[_loc5_].gotoAndStop(12);
  1154.                   }
  1155.                   break;
  1156.                case "a":
  1157.                   _loc4_ = _loc4_ + 1;
  1158.                   this.add_monster("a",x,y,_loc4_);
  1159.                   break;
  1160.                case "s":
  1161.                   _loc4_ = _loc4_ + 1;
  1162.                   this.add_monster("s",x,y,_loc4_);
  1163.                   break;
  1164.                case "d":
  1165.                   _loc4_ = _loc4_ + 1;
  1166.                   this.add_monster("d",x,y,_loc4_);
  1167.                   break;
  1168.                case "u":
  1169.                   _loc4_ = _loc4_ + 1;
  1170.                   this.add_monster("u",x,y,_loc4_);
  1171.                   break;
  1172.                case CGame.MONSTER_FISH3_KEY:
  1173.                   _loc4_ = _loc4_ + 1;
  1174.                   this.add_monster(CGame.MONSTER_FISH3_KEY,x,y,_loc4_);
  1175.                   break;
  1176.                case CGame.MONSTER_FISH1_KEY:
  1177.                   _loc4_ = _loc4_ + 1;
  1178.                   this.add_monster(CGame.MONSTER_FISH1_KEY,x,y,_loc4_);
  1179.                   break;
  1180.                case "g":
  1181.                   _loc4_ = _loc4_ + 1;
  1182.                   this.add_coconut("g",x,y,_loc4_);
  1183.                   break;
  1184.                case "j":
  1185.                   _loc4_ = _loc4_ + 1;
  1186.                   this.add_coconut("j",x,y,_loc4_);
  1187.                   break;
  1188.                case "@":
  1189.                   _loc4_ = _loc4_ + 1;
  1190.                   _loc5_ = "tiles" + _loc4_;
  1191.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1192.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1193.                   _loc6_[_loc5_].gotoAndStop(13);
  1194.                   break;
  1195.                case "-":
  1196.                   _loc4_ = _loc4_ + 1;
  1197.                   _loc5_ = "tiles" + _loc4_;
  1198.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1199.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1200.                   _loc6_[_loc5_].gotoAndStop(21);
  1201.                   break;
  1202.                case "#":
  1203.                   _loc4_ = _loc4_ + 1;
  1204.                   _loc5_ = "tiles" + _loc4_;
  1205.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1206.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1207.                   _loc6_[_loc5_].gotoAndStop(14);
  1208.                   break;
  1209.                case "=":
  1210.                   _loc4_ = _loc4_ + 1;
  1211.                   _loc5_ = "tiles" + _loc4_;
  1212.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1213.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1214.                   _loc6_[_loc5_].gotoAndStop(22);
  1215.                   break;
  1216.                case "$":
  1217.                   _loc4_ = _loc4_ + 1;
  1218.                   _loc5_ = "tiles" + _loc4_;
  1219.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1220.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1221.                   _loc6_[_loc5_].gotoAndStop(15);
  1222.                   break;
  1223.                case "(":
  1224.                   _loc4_ = _loc4_ + 1;
  1225.                   _loc5_ = "tiles" + _loc4_;
  1226.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1227.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1228.                   _loc6_[_loc5_].gotoAndStop(19);
  1229.                   break;
  1230.                case ")":
  1231.                   _loc4_ = _loc4_ + 1;
  1232.                   _loc5_ = "tiles" + _loc4_;
  1233.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1234.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1235.                   _loc6_[_loc5_].gotoAndStop(20);
  1236.                   break;
  1237.                case "%":
  1238.                   _loc4_ = _loc4_ + 1;
  1239.                   _loc5_ = "tiles" + _loc4_;
  1240.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1241.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1242.                   _loc6_[_loc5_].gotoAndStop(17);
  1243.                   break;
  1244.                case "^":
  1245.                   _loc4_ = _loc4_ + 1;
  1246.                   _loc5_ = "tiles" + _loc4_;
  1247.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1248.                   _loc6_.attachMovie("z_obj",_loc5_,_root.decor_depth0 + _loc4_,_loc7_);
  1249.                   _loc6_[_loc5_].gotoAndStop(18);
  1250.                   break;
  1251.                case "z":
  1252.                   _loc4_ = _loc4_ + 1;
  1253.                   _loc5_ = "tiles" + _loc4_;
  1254.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 2});
  1255.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1256.                   if(this._ready)
  1257.                   {
  1258.                      _loc6_[_loc5_].gotoAndStop(3);
  1259.                   }
  1260.                   else
  1261.                   {
  1262.                      _loc6_[_loc5_].gotoAndStop(2);
  1263.                      _loc6_[_loc5_].body.indicator.Value = this._diams;
  1264.                   }
  1265.                   break;
  1266.                case "x":
  1267.                   _loc4_ = _loc4_ + 1;
  1268.                   _loc5_ = "tiles" + _loc4_;
  1269.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1270.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1271.                   _loc6_[_loc5_].gotoAndStop(4);
  1272.                   _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
  1273.                   break;
  1274.                case "m":
  1275.                   _loc4_ = _loc4_ + 1;
  1276.                   _loc5_ = "tiles" + _loc4_;
  1277.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1278.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1279.                   _loc6_[_loc5_].gotoAndStop(5);
  1280.                   _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
  1281.                   break;
  1282.                case "n":
  1283.                   _loc4_ = _loc4_ + 1;
  1284.                   _loc5_ = "tiles" + _loc4_;
  1285.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1286.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1287.                   _loc6_[_loc5_].gotoAndStop(8);
  1288.                   _loc6_[_loc5_].onEnterFrame = function()
  1289.                   {
  1290.                      var _loc3_ = Math.random() * this.TILEW - this.TILEW / 2;
  1291.                      _root.main.game.add_buble(this.x + _loc3_,this.y + this.TILEH / 2);
  1292.                   };
  1293.                   break;
  1294.                case "q":
  1295.                   _loc4_ = _loc4_ + 1;
  1296.                   _loc5_ = "tiles" + _loc4_;
  1297.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1298.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1299.                   _loc6_[_loc5_].gotoAndStop(9);
  1300.                   break;
  1301.                case "w":
  1302.                   _loc4_ = _loc4_ + 1;
  1303.                   _loc5_ = "tiles" + _loc4_;
  1304.                   _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1305.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1306.                   _loc6_[_loc5_].gotoAndStop(10);
  1307.                   break;
  1308.                case "v":
  1309.                   _loc4_ = _loc4_ + 1;
  1310.                   _loc5_ = "tiles" + _loc4_;
  1311.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5});
  1312.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1313.                   _loc6_[_loc5_].gotoAndStop(6);
  1314.                   break;
  1315.                case "b":
  1316.                   _loc4_ = _loc4_ + 1;
  1317.                   _loc5_ = "tiles" + _loc4_;
  1318.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5});
  1319.                   _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1320.                   _loc6_[_loc5_].gotoAndStop(7);
  1321.                   break;
  1322.                case "h":
  1323.                   if(_global.show_tips)
  1324.                   {
  1325.                      _loc4_ = _loc4_ + 1;
  1326.                      _loc5_ = "tiles" + _loc4_;
  1327.                      _loc7_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1328.                      _loc6_.attachMovie("z_obj",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1329.                      _loc6_[_loc5_].gotoAndStop(11);
  1330.                      _loc6_[_loc5_].body.gotoAndPlay(_global._tc);
  1331.                   }
  1332.                   break;
  1333.                case "k":
  1334.                   _loc4_ = _loc4_ + 1;
  1335.                   _loc5_ = "tiles" + _loc4_;
  1336.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1337.                   _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1338.                   _loc6_[_loc5_].gotoAndStop(10);
  1339.                   _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
  1340.                   break;
  1341.                case "f":
  1342.                   _loc4_ = _loc4_ + 1;
  1343.                   _loc5_ = "tiles" + _loc4_;
  1344.                   _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1345.                   _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1346.                   _loc6_[_loc5_].gotoAndStop(11);
  1347.                   _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
  1348.                   break;
  1349.                default:
  1350.                   if(_loc11_ > 2)
  1351.                   {
  1352.                      _loc4_ = _loc4_ + 1;
  1353.                      _loc5_ = "tiles" + _loc4_;
  1354.                      _loc7_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1355.                      _loc6_.attachMovie("tiles1_bonuses",_loc5_,_root.bonus_depth + _loc4_,_loc7_);
  1356.                      _loc6_[_loc5_].gotoAndStop(_loc11_ - 2);
  1357.                      _loc6_[_loc5_].body2.gotoAndPlay(_global._tc);
  1358.                   }
  1359.                   break;
  1360.             }
  1361.          }
  1362.          y++;
  1363.       }
  1364.    }
  1365.    function show_last_screen()
  1366.    {
  1367.       var _loc19_ = 400 / this.TILEW;
  1368.       var _loc20_ = 300 / this.TILEH;
  1369.       _root.createEmptyMovieClip("ts_mc",_root.last_bg_depth);
  1370.       var _loc5_ = 0;
  1371.       var _loc4_ = "";
  1372.       var _loc6_ = undefined;
  1373.       var _loc12_ = -1;
  1374.       while(_loc12_ < _loc20_ + 1)
  1375.       {
  1376.          var _loc9_ = -1;
  1377.          while(_loc9_ < _loc19_ + 1)
  1378.          {
  1379.             var x = _loc9_ + Math.round(this._map_x / this.TILEW);
  1380.             var y = _loc12_ + Math.round(this._map_y / this.TILEH);
  1381.             var _loc7_ = this._lvls[x][y];
  1382.             var _loc8_ = this._lvls_gfxbg[x][y];
  1383.             if(_loc8_[0] != 0)
  1384.             {
  1385.                _loc5_ = _loc5_ + 1;
  1386.                _loc4_ = "tiles" + _loc5_;
  1387.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y - 10 + _loc8_[3],_xscale:_loc8_[1],_yscale:_loc8_[1]});
  1388.                if(_loc8_[2] != 2)
  1389.                {
  1390.                   _root.main.ts_mc.attachMovie("tiles_decor" + _loc8_[0],_loc4_,_root["decor_depth" + _loc8_[2]] / 1 + _loc5_,_loc6_);
  1391.                }
  1392.                else
  1393.                {
  1394.                   _root.main.ts2_mc.attachMovie("tiles_decor" + _loc8_[0],_loc4_,_root["decor_depth" + _loc8_[2]] / 1 + _loc5_,_loc6_);
  1395.                }
  1396.             }
  1397.             var _loc10_ = _loc7_ / 1 + 1;
  1398.             if(this._lvls_type[x][y] != 0)
  1399.             {
  1400.                _loc5_ = _loc5_ + 1;
  1401.                _loc4_ = "tiles" + _loc5_;
  1402.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y});
  1403.                _root.ts_mc.attachMovie("tiles_ground" + this._lvls_type[x][y],_loc4_,_root.tiles_depth + _loc5_,_loc6_);
  1404.                if(this._lvls_rot[x][y] > 0)
  1405.                {
  1406.                   _root.ts_mc[_loc4_]._rotation -= 90 * this._lvls_rot[x][y];
  1407.                }
  1408.             }
  1409.             else if(_loc7_ == "a")
  1410.             {
  1411.                this.add_monster("a",x,y);
  1412.             }
  1413.             else if(_loc7_ == "s")
  1414.             {
  1415.                this.add_monster("s",x,y);
  1416.             }
  1417.             else if(_loc7_ == "d")
  1418.             {
  1419.                this.add_monster("d",x,y);
  1420.             }
  1421.             else if(_loc7_ == "z")
  1422.             {
  1423.                _loc5_ = _loc5_ + 1;
  1424.                _loc4_ = "tiles" + _loc5_;
  1425.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 2,_width:this.TILEW,_height:this.TILEH});
  1426.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1427.                if(this._ready)
  1428.                {
  1429.                   _root.ts_mc[_loc4_].gotoAndStop(3);
  1430.                }
  1431.                else
  1432.                {
  1433.                   _root.ts_mc[_loc4_].gotoAndStop(2);
  1434.                }
  1435.             }
  1436.             else if(_loc7_ == "x")
  1437.             {
  1438.                _loc5_ = _loc5_ + 1;
  1439.                _loc4_ = "tiles" + _loc5_;
  1440.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1441.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1442.                _root.ts_mc[_loc4_].gotoAndStop(4);
  1443.                _root.ts_mc[_loc4_].body.gotoAndPlay(_global._tc);
  1444.             }
  1445.             else if(_loc7_ == "m")
  1446.             {
  1447.                _loc5_ = _loc5_ + 1;
  1448.                _loc4_ = "tiles" + _loc5_;
  1449.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1450.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1451.                _root.ts_mc[_loc4_].gotoAndStop(5);
  1452.                _root.ts_mc[_loc4_].body.gotoAndPlay(_global._tc);
  1453.             }
  1454.             else if(_loc7_ == "n")
  1455.             {
  1456.                _loc5_ = _loc5_ + 1;
  1457.                _loc4_ = "tiles" + _loc5_;
  1458.                _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1459.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1460.                _root.ts_mc[_loc4_].gotoAndStop(8);
  1461.                _root.ts_mc[_loc4_].onEnterFrame = function()
  1462.                {
  1463.                   var _loc3_ = Math.random() * this.TILEW - this.TILEW / 2;
  1464.                   _root.game.add_buble(this.x + _loc3_,this.y + this.TILEH / 2);
  1465.                };
  1466.             }
  1467.             else if(_loc7_ == "q")
  1468.             {
  1469.                _loc5_ = _loc5_ + 1;
  1470.                _loc4_ = "tiles" + _loc5_;
  1471.                _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1472.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1473.                _root.ts_mc[_loc4_].gotoAndStop(9);
  1474.             }
  1475.             else if(_loc7_ == "w")
  1476.             {
  1477.                _loc5_ = _loc5_ + 1;
  1478.                _loc4_ = "tiles" + _loc5_;
  1479.                _loc6_ = new Object({x:this.get_x_scr(x),y:this.get_y_scr(y),_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1480.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1481.                _root.ts_mc[_loc4_].gotoAndStop(10);
  1482.             }
  1483.             else if(_loc7_ == "v")
  1484.             {
  1485.                _loc5_ = _loc5_ + 1;
  1486.                _loc4_ = "tiles" + _loc5_;
  1487.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5,_width:this.TILEW,_height:this.TILEH});
  1488.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1489.                _root.ts_mc[_loc4_].gotoAndStop(6);
  1490.                _root.show_tip(6);
  1491.             }
  1492.             else if(_loc7_ == "b")
  1493.             {
  1494.                _loc5_ = _loc5_ + 1;
  1495.                _loc4_ = "tiles" + _loc5_;
  1496.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y + this.TILEH / 1.5,_width:this.TILEW,_height:this.TILEH});
  1497.                _root.ts_mc.attachMovie("z_obj",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1498.                _root.ts_mc[_loc4_].gotoAndStop(7);
  1499.             }
  1500.             else if(_loc10_ > 2)
  1501.             {
  1502.                _loc5_ = _loc5_ + 1;
  1503.                _loc4_ = "tiles" + _loc5_;
  1504.                _loc6_ = new Object({_x:this.get_x_scr(x) - this._map_x,_y:this.get_y_scr(y) + this._map_y,_width:this.TILEW,_height:this.TILEH});
  1505.                _root.ts_mc.attachMovie("tiles1_bonuses",_loc4_,_root.bonus_depth + _loc5_,_loc6_);
  1506.                _root.ts_mc[_loc4_].gotoAndStop(_loc10_ - 2);
  1507.                _root.ts_mc[_loc4_].body2.gotoAndPlay(_global._tc);
  1508.             }
  1509.             _loc9_ = _loc9_ + 1;
  1510.          }
  1511.          _loc12_ = _loc12_ + 1;
  1512.       }
  1513.       this.redt = false;
  1514.    }
  1515.    function get_max_diams()
  1516.    {
  1517.       var _loc4_ = 0;
  1518.       var _loc3_ = 0;
  1519.       while(_loc3_ < this.maxtiles_x)
  1520.       {
  1521.          var _loc2_ = 0;
  1522.          while(_loc2_ < this.maxtiles_y)
  1523.          {
  1524.             if(this._lvls[_loc3_][_loc2_] == "5")
  1525.             {
  1526.                _loc4_ = _loc4_ + 1;
  1527.             }
  1528.             _loc2_ = _loc2_ + 1;
  1529.          }
  1530.          _loc3_ = _loc3_ + 1;
  1531.       }
  1532.       return _loc4_;
  1533.    }
  1534.    function get_start_x()
  1535.    {
  1536.       var _loc3_ = 0;
  1537.       while(_loc3_ < this.maxtiles_x)
  1538.       {
  1539.          var _loc2_ = 0;
  1540.          while(_loc2_ < this.maxtiles_y)
  1541.          {
  1542.             if(this._lvls[_loc3_][_loc2_] == "q")
  1543.             {
  1544.                return _loc3_;
  1545.             }
  1546.             _loc2_ = _loc2_ + 1;
  1547.          }
  1548.          _loc3_ = _loc3_ + 1;
  1549.       }
  1550.    }
  1551.    function get_start_y()
  1552.    {
  1553.       var _loc3_ = 0;
  1554.       while(_loc3_ < this.maxtiles_x)
  1555.       {
  1556.          var _loc2_ = 0;
  1557.          while(_loc2_ < this.maxtiles_y)
  1558.          {
  1559.             if(this._lvls[_loc3_][_loc2_] == "q")
  1560.             {
  1561.                return _loc2_;
  1562.             }
  1563.             _loc2_ = _loc2_ + 1;
  1564.          }
  1565.          _loc3_ = _loc3_ + 1;
  1566.       }
  1567.    }
  1568.    function set_tiles_angle(onlyvisible)
  1569.    {
  1570.       if(onlyvisible == undefined)
  1571.       {
  1572.          onlyvisible = false;
  1573.       }
  1574.       var _loc9_ = this.DRAW_ZONE_W;
  1575.       var _loc10_ = this.DRAW_ZONE_H;
  1576.       var _loc7_ = 0;
  1577.       var _loc5_ = 0;
  1578.       var _loc8_ = this.maxtiles_x;
  1579.       var _loc6_ = this.maxtiles_y;
  1580.       if(onlyvisible && CGame.IS_LEVEL_EDITOR)
  1581.       {
  1582.          _loc7_ = -1 + Math.round(this._map_x / this._tile_size);
  1583.          _loc5_ = -1 + Math.round(this._map_y / this._tile_sizeh);
  1584.          _loc8_ = _loc7_ + _loc9_ + 5;
  1585.          _loc6_ = _loc5_ + _loc10_ + 5;
  1586.       }
  1587.       var _loc4_ = _loc7_;
  1588.       while(_loc4_ < _loc8_)
  1589.       {
  1590.          var _loc2_ = _loc5_;
  1591.          while(_loc2_ < _loc6_)
  1592.          {
  1593.             if(this._lvls[_loc4_][_loc2_] == 0)
  1594.             {
  1595.                var _loc3_ = this.get_tile_angle(_loc4_,_loc2_);
  1596.                this._lvls_type[_loc4_][_loc2_] = _loc3_[0];
  1597.                this._lvls_rot[_loc4_][_loc2_] = _loc3_[1] / 1 - 1;
  1598.                this._lvls_flip[_loc4_][_loc2_] = _loc3_[2] == undefined ? 0 : _loc3_[2];
  1599.             }
  1600.             else
  1601.             {
  1602.                this._lvls_type[_loc4_][_loc2_] = 0;
  1603.                if(!CGame.IS_LEVEL_EDITOR)
  1604.                {
  1605.                   if(this._lvls[_loc4_][_loc2_] == "k")
  1606.                   {
  1607.                      this._lvls[_loc4_][_loc2_] = 11;
  1608.                   }
  1609.                   else if(this._lvls[_loc4_][_loc2_] == "f")
  1610.                   {
  1611.                      this._lvls[_loc4_][_loc2_] = 12;
  1612.                   }
  1613.                }
  1614.             }
  1615.             _loc2_ = _loc2_ + 1;
  1616.          }
  1617.          _loc4_ = _loc4_ + 1;
  1618.       }
  1619.       _loc4_ = _loc7_;
  1620.       while(_loc4_ < _loc8_)
  1621.       {
  1622.          _loc2_ = _loc5_;
  1623.          while(_loc2_ < _loc6_)
  1624.          {
  1625.             if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 7)
  1626.             {
  1627.                this._lvls_type[_loc4_][_loc2_] = 15;
  1628.             }
  1629.             else if(this._lvls_type[_loc4_][_loc2_] == 2 && this._lvls_type[_loc4_][_loc2_ + 1] == 8 && this._lvls_type[_loc4_ - 1][_loc2_] == 0)
  1630.             {
  1631.                this._lvls_type[_loc4_][_loc2_] = 19;
  1632.             }
  1633.             else if(this._lvls_type[_loc4_][_loc2_] == 2 && this._lvls_type[_loc4_][_loc2_ + 1] == 9 && this._lvls_type[_loc4_ + 1][_loc2_] == 0)
  1634.             {
  1635.                this._lvls_type[_loc4_][_loc2_] = 19;
  1636.                this._lvls_flip[_loc4_][_loc2_] = 1;
  1637.                this._lvls_rot[_loc4_][_loc2_] = 0;
  1638.             }
  1639.             else if(this._lvls_type[_loc4_][_loc2_] == 7 && this._lvls_type[_loc4_ - 1][_loc2_] != 0 && this._lvls_type[_loc4_][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] != 0)
  1640.             {
  1641.                this._lvls_type[_loc4_][_loc2_] = 17;
  1642.             }
  1643.             else if(this._lvls_type[_loc4_][_loc2_] == 7 && this._lvls_type[_loc4_ + 1][_loc2_] != 0 && this._lvls_type[_loc4_][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] != 0)
  1644.             {
  1645.                this._lvls_type[_loc4_][_loc2_] = 17;
  1646.                this._lvls_flip[_loc4_][_loc2_] = 1;
  1647.                this._lvls_rot[_loc4_][_loc2_] = 0;
  1648.             }
  1649.             _loc2_ = _loc2_ + 1;
  1650.          }
  1651.          _loc4_ = _loc4_ + 1;
  1652.       }
  1653.       _loc4_ = _loc7_;
  1654.       while(_loc4_ < _loc8_)
  1655.       {
  1656.          _loc2_ = _loc5_;
  1657.          while(_loc2_ < _loc6_)
  1658.          {
  1659.             if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] != 0 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ - 1][_loc2_] == 17)
  1660.             {
  1661.                this._lvls_type[_loc4_][_loc2_] = 16;
  1662.             }
  1663.             else if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] != 0 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] == 0 && this._lvls_type[_loc4_ + 1][_loc2_] == 17)
  1664.             {
  1665.                this._lvls_type[_loc4_][_loc2_] = 16;
  1666.                this._lvls_flip[_loc4_][_loc2_] = 1;
  1667.                this._lvls_rot[_loc4_][_loc2_] = 0;
  1668.             }
  1669.             _loc2_ = _loc2_ + 1;
  1670.          }
  1671.          _loc4_ = _loc4_ + 1;
  1672.       }
  1673.       _loc4_ = _loc7_;
  1674.       while(_loc4_ < _loc8_)
  1675.       {
  1676.          _loc2_ = _loc5_;
  1677.          while(_loc2_ < _loc6_)
  1678.          {
  1679.             if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 16 && this._lvls_type[_loc4_ - 1][_loc2_ + 1] == 17 && this._lvls_type[_loc4_ - 1][_loc2_] == 15)
  1680.             {
  1681.                this._lvls_type[_loc4_][_loc2_] = 18;
  1682.             }
  1683.             else if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ + 1] == 16 && this._lvls_type[_loc4_ + 1][_loc2_ + 1] == 17 && this._lvls_type[_loc4_ + 1][_loc2_] == 15)
  1684.             {
  1685.                this._lvls_type[_loc4_][_loc2_] = 18;
  1686.                this._lvls_flip[_loc4_][_loc2_] = 1;
  1687.                this._lvls_rot[_loc4_][_loc2_] = 0;
  1688.             }
  1689.             _loc2_ = _loc2_ + 1;
  1690.          }
  1691.          _loc4_ = _loc4_ + 1;
  1692.       }
  1693.       _loc4_ = _loc7_;
  1694.       while(_loc4_ < _loc8_)
  1695.       {
  1696.          _loc2_ = _loc5_;
  1697.          while(_loc2_ < _loc6_)
  1698.          {
  1699.             if(this._lvls_type[_loc4_][_loc2_] == 1 && this._lvls_type[_loc4_][_loc2_ - 1] == 1)
  1700.             {
  1701.                this._lvls_type[_loc4_][_loc2_] = 13;
  1702.                this._lvls_type[_loc4_][_loc2_ - 1] = 0;
  1703.             }
  1704.             _loc2_ = _loc2_ + 1;
  1705.          }
  1706.          _loc4_ = _loc4_ + 1;
  1707.       }
  1708.    }
  1709.    function get_tile_angle(x, y)
  1710.    {
  1711.       if(this._lvls[x - 1][y] == 0 || this._lvls[x - 1][y] == undefined)
  1712.       {
  1713.          if(this._lvls[x + 1][y] == 0 || this._lvls[x + 1][y] == undefined)
  1714.          {
  1715.             if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
  1716.             {
  1717.                if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1718.                {
  1719.                   return [1,1];
  1720.                }
  1721.                return [20,1];
  1722.             }
  1723.             if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1724.             {
  1725.                if(this._lvls[x - 1][y - 1] != 0 && this._lvls[x - 1][y - 1] != undefined)
  1726.                {
  1727.                   return [8,1];
  1728.                }
  1729.                if(this._lvls[x + 1][y - 1] != 0)
  1730.                {
  1731.                   return [9,1];
  1732.                }
  1733.                return [7,1];
  1734.             }
  1735.             if(this._lvls[x - 1][y - 1] == 0)
  1736.             {
  1737.                return [11,1];
  1738.             }
  1739.             if(this._lvls[x + 1][y - 1] == 0)
  1740.             {
  1741.                return [12,1];
  1742.             }
  1743.             return [10,1];
  1744.          }
  1745.          if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
  1746.          {
  1747.             if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1748.             {
  1749.                return [2,3];
  1750.             }
  1751.             return [21,1,1];
  1752.          }
  1753.          if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1754.          {
  1755.             return [9,1];
  1756.          }
  1757.          return [12,1];
  1758.       }
  1759.       if(this._lvls[x + 1][y] == 0 || this._lvls[x + 1][y] == undefined)
  1760.       {
  1761.          if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
  1762.          {
  1763.             if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1764.             {
  1765.                return [2,1];
  1766.             }
  1767.             return [21,1];
  1768.          }
  1769.          if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1770.          {
  1771.             return [8,1];
  1772.          }
  1773.          return [11,1];
  1774.       }
  1775.       if(this._lvls[x][y + 1] == 0 || this._lvls[x][y + 1] == undefined)
  1776.       {
  1777.          if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1778.          {
  1779.             return [3,1];
  1780.          }
  1781.          return [1,1];
  1782.       }
  1783.       if(this._lvls[x][y - 1] == 0 || this._lvls[x][y - 1] == undefined)
  1784.       {
  1785.          return [1,1];
  1786.       }
  1787.       return [1,1];
  1788.    }
  1789.    function generate_gfxbg()
  1790.    {
  1791.       var _loc11_ = new Array(1,2,3);
  1792.       var _loc10_ = new Array(4,5,6);
  1793.       var _loc7_ = 0;
  1794.       var _loc4_ = undefined;
  1795.       var _loc5_ = undefined;
  1796.       var _loc6_ = undefined;
  1797.       var _loc8_ = undefined;
  1798.       var _loc9_ = undefined;
  1799.       var _loc3_ = 0;
  1800.       while(_loc3_ < this.maxtiles_y)
  1801.       {
  1802.          _loc9_ = _loc3_ < this.waterlevel_tiley / this._tsh;
  1803.          var _loc2_ = 0;
  1804.          while(_loc2_ < this.maxtiles_x)
  1805.          {
  1806.             _loc4_ = 0;
  1807.             _loc5_ = 1;
  1808.             _loc6_ = 0;
  1809.             _loc8_ = 1;
  1810.             if(Math.random() > 0.8 && this._lvls[_loc2_ + 1][_loc3_] == 0 && this._lvls[_loc2_ - 1][_loc3_] == 0 && this._lvls[_loc2_][_loc3_] == 0 && this._lvls[_loc2_][_loc3_ + 1] != 0 && this._lvls[_loc2_][_loc3_ + 1] != "z")
  1811.             {
  1812.                if(Math.random() > 0.7)
  1813.                {
  1814.                   _loc5_ = 1;
  1815.                }
  1816.                else
  1817.                {
  1818.                   _loc5_ = 2;
  1819.                   _loc6_ = 4;
  1820.                }
  1821.             }
  1822.             if(this._lvls[_loc2_][_loc3_ - 1] == 0)
  1823.             {
  1824.                if(Math.random() > 0.3 && this._lvls[_loc2_][_loc3_] == 0 && this._lvls[_loc2_][_loc3_ + 1] != 0 && this._lvls[_loc2_][_loc3_ + 1] != "z")
  1825.                {
  1826.                   if(Math.random() > 0.3 && this._lvls[_loc2_ + 1][_loc3_] == 0 && this._lvls[_loc2_ - 1][_loc3_] == 0 && this._lvls_gfxbg[_loc2_ - 1][_loc3_][0] == 0)
  1827.                   {
  1828.                      _loc4_ = Helper.GetRandomFromArray(!!_loc9_ ? _loc10_ : _loc11_);
  1829.                   }
  1830.                }
  1831.             }
  1832.             if(_loc7_ == _loc4_)
  1833.             {
  1834.                _loc4_ = 0;
  1835.             }
  1836.             if(_loc4_ != 0)
  1837.             {
  1838.                _loc7_ = _loc4_;
  1839.             }
  1840.             this._lvls_gfxbg[_loc2_][_loc3_] = [_loc4_,(100 - random(20)) * _loc8_,_loc5_,_loc6_];
  1841.             _loc2_ = _loc2_ + 1;
  1842.          }
  1843.          _loc3_ = _loc3_ + 1;
  1844.       }
  1845.    }
  1846.    function monsters_move()
  1847.    {
  1848.       var _loc20_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
  1849.       var _loc5_ = 0;
  1850.       for(; _loc5_ < _loc20_; _loc5_ = _loc5_ + 1)
  1851.       {
  1852.          var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc5_].attributes;
  1853.          if(_loc2_.x - this._map_x < -100 || _loc2_.x - this._map_x > 500)
  1854.          {
  1855.             if(this.hide_monster(_loc5_,_loc2_.x / 1,_loc2_.y / 1))
  1856.             {
  1857.                continue;
  1858.             }
  1859.          }
  1860.          switch(_loc2_.type)
  1861.          {
  1862.             case "a":
  1863.             case "d":
  1864.             case "u":
  1865.             case CGame.MONSTER_FISH3_KEY:
  1866.                var _loc3_ = Number(_loc2_.side / 1);
  1867.                var _loc8_ = _loc2_.x / 1 + _loc3_ * _loc2_.speed;
  1868.                var _loc11_ = _loc2_.y / 1;
  1869.                var _loc7_ = Math.round((_loc8_ - this._tile_size / 2 - _loc3_ * this._tile_size / 2) / this._tile_size);
  1870.                var _loc6_ = Math.round((- _loc11_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  1871.                if(_loc8_ - this._map_x < -100)
  1872.                {
  1873.                   this.hide_monster(_loc5_,_loc7_,_loc6_);
  1874.                }
  1875.                else
  1876.                {
  1877.                   if((_loc0_ = _loc2_.type) !== CGame.MONSTER_FISH3_KEY)
  1878.                   {
  1879.                      if(this._lvls[_loc7_ + _loc3_][_loc6_] == 0 || this._lvls[_loc7_ + _loc3_][_loc6_ - 1] != 0)
  1880.                      {
  1881.                         _loc2_.side *= -1;
  1882.                         return false;
  1883.                      }
  1884.                   }
  1885.                   else if(this._lvls[_loc7_ + _loc3_][_loc6_] == 0)
  1886.                   {
  1887.                      _loc2_.side *= -1;
  1888.                      return false;
  1889.                   }
  1890.                   _loc2_.x = _loc8_;
  1891.                   _loc2_.y = _loc11_;
  1892.                }
  1893.                break;
  1894.             case CGame.MONSTER_FISH1_KEY:
  1895.                if(_loc2_.targetx == undefined)
  1896.                {
  1897.                   _loc2_.targetx = Math.random() * CGame.MONSTER_FISH1_ZONE_W * 2 - CGame.MONSTER_FISH1_ZONE_W;
  1898.                   _loc2_.targety = Math.random() * CGame.MONSTER_FISH1_ZONE_H * 2 - CGame.MONSTER_FISH1_ZONE_H;
  1899.                }
  1900.                var _loc18_ = Math.round((_loc2_.x - this._tile_size / 2) / this._tile_size);
  1901.                var _loc17_ = Math.round((- _loc2_.y - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  1902.                var _loc15_ = _loc2_.targetx;
  1903.                var _loc13_ = _loc2_.targety;
  1904.                var _loc9_ = Math.atan2(_loc13_,_loc15_);
  1905.                var _loc10_ = _loc2_.speed * Math.cos(_loc9_);
  1906.                var _loc14_ = (- _loc2_.speed) * Math.sin(_loc9_);
  1907.                _loc2_.side = _loc10_ < 0 ? -1 : 1;
  1908.                _loc8_ = _loc2_.x / 1 + _loc10_;
  1909.                _loc11_ = _loc2_.y / 1 + _loc14_;
  1910.                _loc7_ = Math.round((_loc8_ - this._tile_size / 2) / this._tile_size);
  1911.                _loc6_ = Math.round((- _loc11_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  1912.                if(_loc8_ - this._map_x < -100)
  1913.                {
  1914.                   this.hide_monster(_loc5_,_loc7_,_loc6_);
  1915.                }
  1916.                else if(this._lvls[_loc7_][_loc6_] == 0 || Math.abs(_loc7_ - _loc2_.init_tx) >= CGame.MONSTER_FISH1_ZONE_W || Math.abs(_loc6_ - _loc2_.init_ty) >= CGame.MONSTER_FISH1_ZONE_H)
  1917.                {
  1918.                   _loc2_.targetx = undefined;
  1919.                }
  1920.                else
  1921.                {
  1922.                   _loc2_.x = _loc8_;
  1923.                   _loc2_.y = _loc11_;
  1924.                }
  1925.                break;
  1926.             case "s":
  1927.                if(_loc2_.speed > 60)
  1928.                {
  1929.                   _loc2_.speed = 1;
  1930.                }
  1931.                else
  1932.                {
  1933.                   _loc2_.speed = _loc2_.speed + 1;
  1934.                }
  1935.                break;
  1936.          }
  1937.       }
  1938.       _loc5_ = 0;
  1939.       while(_loc5_ < this.monsters_to_die.length)
  1940.       {
  1941.          var _loc4_ = this.monsters_to_die[_loc5_];
  1942.          _loc4_.y += CGame.GAME_GRAVITY * 12;
  1943.          var _loc12_ = _loc4_.x - this._map_x;
  1944.          var _loc16_ = _loc4_.y - this._map_y;
  1945.          if(_loc12_ < -100 || _loc12_ > 500 || _loc16_ > 350)
  1946.          {
  1947.             _loc4_.killed = true;
  1948.          }
  1949.          _loc5_ = _loc5_ + 1;
  1950.       }
  1951.       var _loc19_ = new Array();
  1952.       _loc5_ = 0;
  1953.       while(_loc5_ < this.monsters_to_die.length)
  1954.       {
  1955.          if(!this.monsters_to_die[_loc5_].killed)
  1956.          {
  1957.             _loc19_.push(this.monsters_to_die[_loc5_]);
  1958.          }
  1959.          _loc5_ = _loc5_ + 1;
  1960.       }
  1961.       this.monsters_to_die = _loc19_;
  1962.       this.show_monsters();
  1963.    }
  1964.    function show_monsters()
  1965.    {
  1966.       _root.main.gfx_scr.createEmptyMovieClip("monsters_scr",_root.monsters_depth);
  1967.       _root.main.gfx_scr.createEmptyMovieClip("monsters2_scr",_root.monsters_hiden_depth);
  1968.       var _loc13_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes.length;
  1969.       var _loc6_ = 0;
  1970.       for(; _loc6_ < _loc13_; _loc6_ = _loc6_ + 1)
  1971.       {
  1972.          var _loc4_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[_loc6_].attributes;
  1973.          var _loc9_ = "monster" + _loc6_;
  1974.          var _loc10_ = new Object({_x:_loc4_.x,_y:_loc4_.y + this._tile_sizeh / 4});
  1975.          var _loc5_ = 2;
  1976.          if(_loc4_.type == "s")
  1977.          {
  1978.             _loc5_ = 3;
  1979.             if(_loc4_.speed > 12)
  1980.             {
  1981.                _root.main.gfx_scr.monsters2_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_depth + 1 + _loc6_,_loc10_);
  1982.                _root.main.gfx_scr.monsters2_scr[_loc9_].gotoAndStop(_loc5_);
  1983.                _root.main.gfx_scr.monsters2_scr[_loc9_].body.gotoAndStop(1);
  1984.                continue;
  1985.             }
  1986.          }
  1987.          else if(_loc4_.type == "d")
  1988.          {
  1989.             _loc5_ = 4;
  1990.          }
  1991.          else if(_loc4_.type == "u")
  1992.          {
  1993.             _loc5_ = 5;
  1994.          }
  1995.          else if(_loc4_.type == CGame.MONSTER_FISH3_KEY)
  1996.          {
  1997.             _loc5_ = 6;
  1998.          }
  1999.          else if(_loc4_.type == CGame.MONSTER_FISH1_KEY)
  2000.          {
  2001.             _loc5_ = 7;
  2002.          }
  2003.          else if(_loc4_.type == "a")
  2004.          {
  2005.             _loc5_ = 2;
  2006.          }
  2007.          _root.main.gfx_scr.monsters_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_depth + 1 + _loc6_,_loc10_);
  2008.          _root.main.gfx_scr.monsters_scr[_loc9_].gotoAndStop(_loc5_);
  2009.          if(_loc5_ == 3)
  2010.          {
  2011.             _root.main.gfx_scr.monsters_scr[_loc9_].body.gotoAndStop(_loc4_.speed);
  2012.          }
  2013.          else
  2014.          {
  2015.             _root.main.gfx_scr.monsters_scr[_loc9_]._xscale = 100 * _loc4_.side;
  2016.             _root.main.gfx_scr.monsters_scr[_loc9_].body.gotoAndPlay(_global._tc);
  2017.          }
  2018.       }
  2019.       _root.main.gfx_scr.createEmptyMovieClip("monsters_killed_scr",_root.monsters_killed_depth);
  2020.       _loc6_ = 0;
  2021.       while(_loc6_ < this.monsters_to_die.length)
  2022.       {
  2023.          var _loc8_ = this.monsters_to_die[_loc6_];
  2024.          _loc5_ = 2;
  2025.          switch(_loc8_.type)
  2026.          {
  2027.             case "s":
  2028.                _loc5_ = 3;
  2029.                break;
  2030.             case "d":
  2031.                _loc5_ = 4;
  2032.                break;
  2033.             case "u":
  2034.                _loc5_ = 5;
  2035.                break;
  2036.             case CGame.MONSTER_FISH3_KEY:
  2037.                _loc5_ = 6;
  2038.                break;
  2039.             case CGame.MONSTER_FISH1_KEY:
  2040.                _loc5_ = 7;
  2041.                break;
  2042.             case "a":
  2043.                _loc5_ = 2;
  2044.          }
  2045.          _loc9_ = "monster_killed" + _loc6_;
  2046.          _root.main.gfx_scr.monsters_killed_scr.attachMovie("tiles_monsters",_loc9_,_root.monsters_killed_depth + 1 + _loc6_,{_x:_loc8_.x,_y:_loc8_.y + this._tile_sizeh / 4});
  2047.          var _loc7_ = _root.main.gfx_scr.monsters_killed_scr[_loc9_];
  2048.          _loc7_.gotoAndStop(_loc5_);
  2049.          _loc7_._yscale = -100;
  2050.          _loc7_._xscale = 100 * _loc8_.side;
  2051.          _loc7_.body.gotoAndPlay(_global._tc);
  2052.          _loc6_ = _loc6_ + 1;
  2053.       }
  2054.    }
  2055.    function add_monster(type_id, x, y)
  2056.    {
  2057.       var _loc6_ = new XML();
  2058.       var _loc3_ = _loc6_.createElement("mon");
  2059.       _loc3_.attributes.type = type_id;
  2060.       _loc3_.attributes.x = this.get_x_scr(x);
  2061.       _loc3_.attributes.y = this.get_y_scr(y);
  2062.       _loc3_.attributes.side = -1;
  2063.       _loc3_.attributes.speed = 1;
  2064.       if(type_id == "a")
  2065.       {
  2066.          _loc3_.attributes.speed = 0.5;
  2067.       }
  2068.       else if(type_id == "d")
  2069.       {
  2070.          _loc3_.attributes.speed = 3;
  2071.          if(Helper.TIPS_BY_EVENT)
  2072.          {
  2073.             _root.show_tip(7);
  2074.          }
  2075.       }
  2076.       else if(type_id == "u")
  2077.       {
  2078.          _loc3_.attributes.speed = CGame.MONSTER_ULITKA_SPEED;
  2079.       }
  2080.       else if(type_id == CGame.MONSTER_FISH3_KEY)
  2081.       {
  2082.          _loc3_.attributes.speed = CGame.MONSTER_FISH3_SPEED;
  2083.       }
  2084.       else if(type_id == CGame.MONSTER_FISH1_KEY)
  2085.       {
  2086.          _loc3_.attributes.speed = CGame.MONSTER_FISH1_SPEED;
  2087.          _loc3_.attributes.init_tx = x;
  2088.          _loc3_.attributes.init_ty = y;
  2089.       }
  2090.       this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].appendChild(_loc3_);
  2091.       if(Helper.TIPS_BY_EVENT)
  2092.       {
  2093.          _root.show_tip(4);
  2094.       }
  2095.       this._lvls[x][y] = 1;
  2096.       this.show_monsters();
  2097.    }
  2098.    function remove_monster(id)
  2099.    {
  2100.       var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id];
  2101.       _loc2_.removeNode();
  2102.       this.show_monsters();
  2103.    }
  2104.    function kill_monster(id)
  2105.    {
  2106.       trace("kill_monster " + id);
  2107.       var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id].attributes;
  2108.       var _loc2_ = new Object();
  2109.       _loc2_.x = _loc3_.x;
  2110.       _loc2_.y = _loc3_.y;
  2111.       _loc2_.side = _loc3_.side;
  2112.       _loc2_.type = _loc3_.type;
  2113.       _loc2_.yspeed = CGame.MONSTER_DEADFALL_YSPEED;
  2114.       _loc2_.killed = false;
  2115.       this.monsters_to_die.push(_loc2_);
  2116.       this.remove_monster(id);
  2117.    }
  2118.    function hide_monster(id, mx, my)
  2119.    {
  2120.       var _loc4_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
  2121.       var _loc3_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2122.       if(this._lvls[_loc4_][_loc3_] == 1)
  2123.       {
  2124.          var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.MONSTERS_ID].childNodes[id].attributes;
  2125.          if(_loc2_.type == CGame.MONSTER_FISH1_KEY)
  2126.          {
  2127.             if(this._lvls[_loc2_.init_tx][_loc2_.init_ty] != 1)
  2128.             {
  2129.                return false;
  2130.             }
  2131.             this._lvls[_loc2_.init_tx][_loc2_.init_ty] = _loc2_.type;
  2132.          }
  2133.          else
  2134.          {
  2135.             this._lvls[_loc4_][_loc3_] = _loc2_.type;
  2136.          }
  2137.          this.remove_monster(id);
  2138.          return true;
  2139.       }
  2140.       return false;
  2141.    }
  2142.    function get_nearest_diam()
  2143.    {
  2144.       var _loc5_ = -1;
  2145.       var _loc4_ = -1;
  2146.       var _loc3_ = 0;
  2147.       while(_loc3_ < this.maxtiles_x)
  2148.       {
  2149.          var _loc2_ = this.maxtiles_y;
  2150.          while(_loc2_ > 0)
  2151.          {
  2152.             if(this._diams >= this._max_diams)
  2153.             {
  2154.                if(this._lvls[_loc3_][_loc2_] == "z")
  2155.                {
  2156.                   _loc5_ = _loc3_;
  2157.                   _loc4_ = _loc2_ + 1;
  2158.                }
  2159.             }
  2160.             else if(this._lvls[_loc3_][_loc2_] == 5)
  2161.             {
  2162.                _loc5_ = _loc3_;
  2163.                _loc4_ = _loc2_;
  2164.                this._arrowto_x = this.get_x_scr(_loc5_);
  2165.                this._arrowto_y = this.get_y_scr(_loc4_);
  2166.                return true;
  2167.             }
  2168.             _loc2_ = _loc2_ - 1;
  2169.          }
  2170.          _loc3_ = _loc3_ + 1;
  2171.       }
  2172.       this._arrowto_x = this.get_x_scr(_loc5_);
  2173.       this._arrowto_y = this.get_y_scr(_loc4_);
  2174.       return true;
  2175.    }
  2176.    function show_arrow()
  2177.    {
  2178.       var _loc4_ = this._arrowto_x - this._map_x;
  2179.       var _loc3_ = this._arrowto_y + this._map_y;
  2180.       if(_loc4_ > 400)
  2181.       {
  2182.          _loc4_ = 380;
  2183.       }
  2184.       if(_loc4_ < 0)
  2185.       {
  2186.          _loc4_ = 20;
  2187.       }
  2188.       if(_loc3_ > 300)
  2189.       {
  2190.          _loc3_ = 280;
  2191.       }
  2192.       if(_loc3_ < 0)
  2193.       {
  2194.          _loc3_ = 20;
  2195.       }
  2196.       var _loc5_ = Math.atan2(_loc4_ - this._char_x,300 - _loc3_ - this._char_y) * 180 / 3.141592653589793;
  2197.       _root.main.face_scr.arrow_mc._x = _loc4_;
  2198.       _root.main.face_scr.arrow_mc._y = _loc3_;
  2199.       _root.main.face_scr.arrow_mc._rotation = _loc5_;
  2200.    }
  2201.    function elevators_move()
  2202.    {
  2203.       var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
  2204.       var _loc3_ = 0;
  2205.       for(; _loc3_ < _loc9_; _loc3_ = _loc3_ + 1)
  2206.       {
  2207.          var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc3_].attributes;
  2208.          switch(_loc2_.type)
  2209.          {
  2210.             case "e":
  2211.                var _loc8_ = Number(_loc2_.side / 1);
  2212.                var _loc5_ = _loc2_.x / 1;
  2213.                var _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
  2214.                var _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
  2215.                var _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2216.                if((this._lvls[_loc7_][_loc6_ - _loc8_] == "r" || this._lvls[_loc7_][_loc6_ - _loc8_] == "E") && Number(_loc2_.state) == 0)
  2217.                {
  2218.                   _loc2_.state = 1;
  2219.                }
  2220.                else if(_loc2_.state == 1 && (this._lvls[_loc7_][_loc6_] == "r" || this._lvls[_loc7_][_loc6_] == "E"))
  2221.                {
  2222.                   _loc2_.side *= -1;
  2223.                   _loc2_.state = 2;
  2224.                }
  2225.                else if(_loc2_.state == 2)
  2226.                {
  2227.                   _loc2_.state = 0;
  2228.                }
  2229.                _loc2_.x = _loc5_;
  2230.                _loc2_.y = _loc4_;
  2231.                break;
  2232.             case "o":
  2233.                _loc8_ = Number(_loc2_.side / 1);
  2234.                _loc5_ = _loc2_.x / 1 - _loc8_ * _loc2_.speed;
  2235.                _loc4_ = _loc2_.y / 1;
  2236.                _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
  2237.                _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2238.                if(this._lvls[_loc7_ - _loc8_][_loc6_] == "p" || this._lvls[_loc7_ - _loc8_][_loc6_] == "O")
  2239.                {
  2240.                   _loc2_.side *= -1;
  2241.                }
  2242.                _loc2_.x = _loc5_;
  2243.                _loc2_.y = _loc4_;
  2244.                break;
  2245.             case "t":
  2246.                switch(_loc2_.state)
  2247.                {
  2248.                   case CGame.ELEVATOR_STATE_WAIT:
  2249.                      if(this._char_on_elev && this._char_on_elev_id == _loc3_)
  2250.                      {
  2251.                         _loc2_.side = -1;
  2252.                         _loc2_.state = CGame.ELEVATOR_STATE_GO;
  2253.                      }
  2254.                      break;
  2255.                   case CGame.ELEVATOR_STATE_GO:
  2256.                      _loc8_ = Number(_loc2_.side / 1);
  2257.                      _loc5_ = _loc2_.x / 1;
  2258.                      _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
  2259.                      _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
  2260.                      _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2261.                      if(this._lvls[_loc7_][_loc6_] != "y")
  2262.                      {
  2263.                         _loc2_.x = _loc5_;
  2264.                         _loc2_.y = _loc4_;
  2265.                         break;
  2266.                      }
  2267.                      _loc2_.stoptime = CGame.ELEVATOR_STOP_TIME;
  2268.                      _loc2_.state = CGame.ELEVATOR_STATE_TIMESTOP;
  2269.                      continue;
  2270.                   case CGame.ELEVATOR_STATE_TIMESTOP:
  2271.                      _loc2_.stoptime = _loc2_.stoptime - 1;
  2272.                      if(_loc2_.stoptime <= 0)
  2273.                      {
  2274.                         _loc2_.side = 1;
  2275.                         _loc2_.state = CGame.ELEVATOR_STATE_GOBACK;
  2276.                      }
  2277.                      break;
  2278.                   case CGame.ELEVATOR_STATE_GOBACK:
  2279.                      _loc8_ = Number(_loc2_.side / 1);
  2280.                      _loc5_ = _loc2_.x / 1;
  2281.                      _loc4_ = _loc2_.y / 1 + _loc8_ * _loc2_.speed;
  2282.                      _loc7_ = Math.round((_loc5_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
  2283.                      _loc6_ = Math.round((- _loc4_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2284.                      if(this._lvls[_loc7_][_loc6_] != "T")
  2285.                      {
  2286.                         _loc2_.x = _loc5_;
  2287.                         _loc2_.y = _loc4_;
  2288.                         break;
  2289.                      }
  2290.                      _loc2_.state = CGame.ELEVATOR_STATE_WAIT;
  2291.                      continue;
  2292.                }
  2293.                break;
  2294.          }
  2295.       }
  2296.       this.show_elevators();
  2297.    }
  2298.    function show_elevators()
  2299.    {
  2300.       _root.main.gfx_scr.createEmptyMovieClip("elevators_scr",_root.elevators_depth);
  2301.       var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes.length;
  2302.       var _loc3_ = 0;
  2303.       while(_loc3_ < _loc9_)
  2304.       {
  2305.          var _loc4_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[_loc3_].attributes;
  2306.          var _loc5_ = "elevator" + _loc3_;
  2307.          var _loc6_ = new Object({_x:_loc4_.x,_y:_loc4_.y});
  2308.          _root.main.gfx_scr.elevators_scr.attachMovie("mapEvelator",_loc5_,_root.elevators_depth + 1 + _loc3_,_loc6_);
  2309.          _loc4_.wide2 = _root.main.gfx_scr.elevators_scr[_loc5_]._width / 2;
  2310.          _loc3_ = _loc3_ + 1;
  2311.       }
  2312.    }
  2313.    function add_elevator(type_id, x, y)
  2314.    {
  2315.       var _loc10_ = new XML();
  2316.       var _loc5_ = _loc10_.createElement("elev");
  2317.       _loc5_.attributes.type = type_id;
  2318.       _loc5_.attributes.x = this.get_x_scr(x);
  2319.       _loc5_.attributes.y = this.get_y_scr(y);
  2320.       _loc5_.attributes.side = -1;
  2321.       _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
  2322.       _loc5_.attributes.wide2 = this._tile_size / 2;
  2323.       _loc5_.attributes.state = 0;
  2324.       if(type_id == "e")
  2325.       {
  2326.          _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
  2327.          this._lvls[x][y] = "E";
  2328.          var _loc7_ = 200;
  2329.          var _loc6_ = 200;
  2330.          var _loc3_ = y - 1;
  2331.          while(_loc3_ > y - 100)
  2332.          {
  2333.             if(this._lvls[x][_loc3_] == "r")
  2334.             {
  2335.                _loc7_ = y - _loc3_;
  2336.                break;
  2337.             }
  2338.             _loc3_ = _loc3_ - 1;
  2339.          }
  2340.          _loc3_ = y + 1;
  2341.          while(_loc3_ < y + 100)
  2342.          {
  2343.             if(this._lvls[x][_loc3_] == "r")
  2344.             {
  2345.                _loc6_ = _loc3_ - y;
  2346.                break;
  2347.             }
  2348.             _loc3_ = _loc3_ + 1;
  2349.          }
  2350.          if(_loc6_ == 200 && _loc7_ != 200)
  2351.          {
  2352.             _loc5_.attributes.speed = - this.ELEVATOR_E_SPEED;
  2353.          }
  2354.       }
  2355.       else if(type_id == "t")
  2356.       {
  2357.          _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
  2358.          _loc5_.attributes.state = CGame.ELEVATOR_STATE_WAIT;
  2359.          _loc5_.attributes.stoptime = 0;
  2360.          this._lvls[x][y] = "T";
  2361.          _loc7_ = 200;
  2362.          _loc6_ = 200;
  2363.          _loc3_ = y - 1;
  2364.          while(_loc3_ > y - 100)
  2365.          {
  2366.             if(this._lvls[x][_loc3_] == "y")
  2367.             {
  2368.                _loc7_ = y - _loc3_;
  2369.                break;
  2370.             }
  2371.             _loc3_ = _loc3_ - 1;
  2372.          }
  2373.          _loc3_ = y + 1;
  2374.          while(_loc3_ < y + 100)
  2375.          {
  2376.             if(this._lvls[x][_loc3_] == "y")
  2377.             {
  2378.                _loc6_ = _loc3_ - y;
  2379.                break;
  2380.             }
  2381.             _loc3_ = _loc3_ + 1;
  2382.          }
  2383.          if(_loc6_ == 200 && _loc7_ != 200)
  2384.          {
  2385.             _loc5_.attributes.speed = - this.ELEVATOR_E_SPEED;
  2386.          }
  2387.       }
  2388.       else if(type_id == "o")
  2389.       {
  2390.          _loc5_.attributes.speed = this.ELEVATOR_E_SPEED;
  2391.          this._lvls[x][y] = "O";
  2392.       }
  2393.       if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID] == undefined)
  2394.       {
  2395.          var _loc9_ = this._map_xml.createElement("elevators");
  2396.          this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID] = _loc9_;
  2397.       }
  2398.       this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].appendChild(_loc5_);
  2399.       this.show_elevators();
  2400.    }
  2401.    function remove_elevator(id)
  2402.    {
  2403.       var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[id];
  2404.       _loc2_.removeNode();
  2405.       this.show_elevators();
  2406.    }
  2407.    function hide_elevator(id, mx, my)
  2408.    {
  2409.       var _loc3_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
  2410.       var _loc2_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2411.       if(this._lvls[_loc3_][_loc2_] == 1)
  2412.       {
  2413.          this._lvls[_loc3_][_loc2_] = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.ELEVATORS_ID].childNodes[id].attributes.type;
  2414.          this.remove_elevator(id);
  2415.          return true;
  2416.       }
  2417.       return false;
  2418.    }
  2419.    function coconuts_move()
  2420.    {
  2421.       var _loc12_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
  2422.       var _loc4_ = 0;
  2423.       for(; _loc4_ < _loc12_; _loc4_ = _loc4_ + 1)
  2424.       {
  2425.          var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc4_].attributes;
  2426.          if((_loc3_.state == CGame.COCONUT_STATE_WAIT || _loc3_.state == CGame.COCONUT_STATE_STRESS) && (_loc3_.x - this._map_x < -100 || _loc3_.x - this._map_x > 500))
  2427.          {
  2428.             if(this.hide_coconut(_loc4_,_loc3_.x / 1,_loc3_.y / 1))
  2429.             {
  2430.                continue;
  2431.             }
  2432.          }
  2433.          if(_loc3_.state == CGame.COCONUT_STATE_FIRE && (_loc3_.x - this._map_x < -100 || _loc3_.x - this._map_x > 500))
  2434.          {
  2435.             this.remove_coconut(_loc4_);
  2436.             continue;
  2437.          }
  2438.          if(!(_loc3_.type == "g" || _loc3_.type == "j"))
  2439.          {
  2440.             continue;
  2441.          }
  2442.          switch(_loc3_.state)
  2443.          {
  2444.             case CGame.COCONUT_STATE_WAIT:
  2445.                var _loc5_ = this._char_x + this._map_x;
  2446.                var _loc11_ = this._char_y + this._map_y;
  2447.                if(_loc5_ > _loc3_.x - CGame.COCONUT_FALL_ZONE && _loc5_ < _loc3_.x + CGame.COCONUT_FALL_ZONE)
  2448.                {
  2449.                   _loc3_.timer = CGame.COCONUT_STRESS_TIME;
  2450.                   _loc3_.state = CGame.COCONUT_STATE_STRESS;
  2451.                   _root.snd_fruit_shake.start();
  2452.                }
  2453.                break;
  2454.             case CGame.COCONUT_STATE_STRESS:
  2455.                _loc3_.timer = _loc3_.timer - 1;
  2456.                if(_loc3_.timer <= 0)
  2457.                {
  2458.                   _loc3_.diffx = 0;
  2459.                   _loc3_.diffy = 0;
  2460.                   _loc3_.state = CGame.COCONUT_STATE_FALL;
  2461.                   _root.snd_fruit_fall.start();
  2462.                }
  2463.                else
  2464.                {
  2465.                   _loc3_.diffx = 3 - 6 * Math.random();
  2466.                   _loc3_.diffy = 3 - 6 * Math.random();
  2467.                }
  2468.                break;
  2469.             case CGame.COCONUT_STATE_FALL:
  2470.                _loc3_.yspeed += CGame.COCONUT_GRAVITY;
  2471.                var _loc10_ = _loc3_.x / 1 + _loc3_.xspeed;
  2472.                var _loc9_ = _loc3_.y / 1 + _loc3_.yspeed;
  2473.                var _loc8_ = Math.round((_loc10_ - this._tile_size / 2 - this._tile_size / 2) / this._tile_size);
  2474.                var _loc6_ = Math.round((- _loc9_ - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2475.                if(this._lvls[_loc8_][_loc6_] == 0)
  2476.                {
  2477.                   var _loc7_ = this.get_y_scr(_loc6_);
  2478.                   _loc9_ = _loc7_ - this._tile_sizeh / 2;
  2479.                   _loc3_.state = CGame.COCONUT_STATE_LIE;
  2480.                }
  2481.                _loc3_.x = _loc10_;
  2482.                _loc3_.y = _loc9_;
  2483.                break;
  2484.             case CGame.COCONUT_STATE_LIE:
  2485.                break;
  2486.             case CGame.COCONUT_STATE_FIRE:
  2487.                _loc3_.yspeed += CGame.COCONUT_GRAVITY;
  2488.                _loc10_ = _loc3_.x / 1 + _loc3_.xspeed;
  2489.                _loc9_ = _loc3_.y / 1 + _loc3_.yspeed;
  2490.                _loc3_.x = _loc10_;
  2491.                _loc3_.y = _loc9_;
  2492.                break;
  2493.          }
  2494.       }
  2495.       this.show_coconuts();
  2496.    }
  2497.    function show_coconuts()
  2498.    {
  2499.       _root.main.gfx_scr.createEmptyMovieClip("coconuts_scr",_root.coconuts_depth);
  2500.       var _loc9_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes.length;
  2501.       var _loc4_ = 0;
  2502.       while(_loc4_ < _loc9_)
  2503.       {
  2504.          var _loc3_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[_loc4_].attributes;
  2505.          var _loc5_ = "coconut" + _loc4_;
  2506.          var _loc6_ = new Object({_x:_loc3_.x + _loc3_.diffx,_y:_loc3_.y + _loc3_.diffy});
  2507.          _root.main.gfx_scr.coconuts_scr.attachMovie("mapCoconut",_loc5_,_root.coconuts_depth + 1 + _loc4_,_loc6_);
  2508.          if(_loc3_.type == "j")
  2509.          {
  2510.             _root.main.gfx_scr.coconuts_scr[_loc5_].gotoAndStop(2);
  2511.          }
  2512.          _loc4_ = _loc4_ + 1;
  2513.       }
  2514.    }
  2515.    function add_coconut(type_id, x, y)
  2516.    {
  2517.       var _loc5_ = new XML();
  2518.       var _loc2_ = _loc5_.createElement("coconut");
  2519.       _loc2_.attributes.type = type_id;
  2520.       _loc2_.attributes.state = CGame.COCONUT_STATE_WAIT;
  2521.       _loc2_.attributes.x = this.get_x_scr(x);
  2522.       _loc2_.attributes.y = this.get_y_scr(y);
  2523.       _loc2_.attributes.diffx = 0;
  2524.       _loc2_.attributes.diffy = 0;
  2525.       _loc2_.attributes.timer = 0;
  2526.       _loc2_.attributes.yspeed = 1;
  2527.       if(type_id == "g")
  2528.       {
  2529.          _loc2_.attributes.xspeed = -2;
  2530.       }
  2531.       else if(type_id == "j")
  2532.       {
  2533.          _loc2_.attributes.xspeed = 2;
  2534.       }
  2535.       this._lvls[x][y] = 1;
  2536.       if(this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID] == undefined)
  2537.       {
  2538.          var _loc3_ = this._map_xml.createElement("coconuts");
  2539.          this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID] = _loc3_;
  2540.       }
  2541.       this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].appendChild(_loc2_);
  2542.       this.show_coconuts();
  2543.    }
  2544.    function remove_coconut(id)
  2545.    {
  2546.       var _loc2_ = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[id];
  2547.       _loc2_.removeNode();
  2548.       this.show_coconuts();
  2549.    }
  2550.    function hide_coconut(id, mx, my)
  2551.    {
  2552.       var _loc3_ = Math.round((mx - this._tile_size / 2) / this._tile_size);
  2553.       var _loc2_ = Math.round((- my - this._tile_sizeh / 2 + this._game_height) / this._tile_sizeh);
  2554.       if(this._lvls[_loc3_][_loc2_] == 1)
  2555.       {
  2556.          this._lvls[_loc3_][_loc2_] = this._map_xml.firstChild.childNodes[this._current_map].childNodes[CGame.COCONUTS_ID].childNodes[id].attributes.type;
  2557.          this.remove_coconut(id);
  2558.          return true;
  2559.       }
  2560.       return false;
  2561.    }
  2562.    function add_hp(hp)
  2563.    {
  2564.       this._chp += hp;
  2565.       if(this._chp > this._chp_max)
  2566.       {
  2567.          this._chp = this._chp_max;
  2568.       }
  2569.       var _loc3_ = this._chp / this._chp_max;
  2570.       if(_loc3_ <= 0.25)
  2571.       {
  2572.          _root.main.face_scr.hp_bar.shine_mc.play();
  2573.       }
  2574.       _root.main.face_scr.mcShells.SetValue(this._chp);
  2575.       if(this._chp <= 0)
  2576.       {
  2577.          _root.hero_death.start();
  2578.          this.lose_game(1);
  2579.          return false;
  2580.       }
  2581.    }
  2582.    function add_mp(mp)
  2583.    {
  2584.       return undefined;
  2585.    }
  2586.    function add_explosion(x, y, type_id)
  2587.    {
  2588.       this._exps = this._exps + 1;
  2589.       var _loc3_ = "z_exps" + this._exps;
  2590.       var _loc4_ = new Object({_x:x,_y:y});
  2591.       _root.main.gfx_scr.attachMovie("z_exps",_loc3_,_root.stars_depth + this._exps,_loc4_);
  2592.       _root.main.gfx_scr[_loc3_].gotoAndStop(type_id);
  2593.       if(this._exps > 50)
  2594.       {
  2595.          this._exps = 0;
  2596.       }
  2597.    }
  2598.    function add_buble(x, y)
  2599.    {
  2600.       _root.main.gfx_scr.attachMovie("bubble2","bubles" + this.buble_id,_root.bubles_depth + this.buble_id,{_x:x,_y:y});
  2601.       if(this.buble_id > 8)
  2602.       {
  2603.          this.buble_id = 0;
  2604.       }
  2605.       else
  2606.       {
  2607.          this.buble_id = this.buble_id + 1;
  2608.       }
  2609.    }
  2610.    function add_turtle()
  2611.    {
  2612.       var _loc6_ = this.get_start_x();
  2613.       var _loc5_ = this.get_start_y();
  2614.       if(this._checkpoint_x != -1)
  2615.       {
  2616.          _loc6_ = this._checkpoint_x;
  2617.          _loc5_ = this._checkpoint_y;
  2618.       }
  2619.       this._char_x = _loc6_ * this._ts / 1 + this._ts2;
  2620.       this._char_y = _loc5_ * this._tsh / 1;
  2621.       if(this._char_x > this._game_width / 2)
  2622.       {
  2623.          this._map_x = this._char_x - this._game_width / 2;
  2624.          this._char_x = this._game_width / 2;
  2625.       }
  2626.       if(this._char_y > this._game_height / 2)
  2627.       {
  2628.          this._map_y = this._char_y - this._game_height / 2;
  2629.          this._char_y = this._game_height / 2;
  2630.       }
  2631.       _root.main.attachMovie("char","char",_root.char_depth);
  2632.       MovieClip(_root.main.char).hitArea = _root.main.char.mcHitArea;
  2633.       _root.main.char.mcHitArea._visible = false;
  2634.       var _loc4_ = new Object();
  2635.       _loc4_.onKeyDown = function()
  2636.       {
  2637.          _root.anykey_pressed = true;
  2638.          if(!_global._game_paused)
  2639.          {
  2640.             switch(Key.getCode())
  2641.             {
  2642.                case 39:
  2643.                   _root.main.game.move(1);
  2644.                   break;
  2645.                case 37:
  2646.                   _root.main.game.move(-1);
  2647.                   break;
  2648.                case 27:
  2649.                   _root.show_escmenu();
  2650.                   break;
  2651.                case 17:
  2652.                case 32:
  2653.                   _root.main.game.jump_char();
  2654.             }
  2655.          }
  2656.       };
  2657.       _loc4_.onKeyUp = function()
  2658.       {
  2659.          _root.anykey_pressed = true;
  2660.          switch(Key.getCode())
  2661.          {
  2662.             case 39:
  2663.             case 37:
  2664.                _root.main.game._csx = 0;
  2665.          }
  2666.       };
  2667.       if(Key._listeners.length == 0)
  2668.       {
  2669.          Key.addListener(_loc4_);
  2670.       }
  2671.       _root.main.char.onEnterFrame = function()
  2672.       {
  2673.          if(!_global._game_paused)
  2674.          {
  2675.             if(Key.isDown(32) || Key.isDown(17) || Key.isDown(38))
  2676.             {
  2677.                _root.main.game.jump_char();
  2678.             }
  2679.             if(Key.isDown(37) || Key.isDown(39))
  2680.             {
  2681.                if(Key.isDown(37))
  2682.                {
  2683.                   _root.main.game.move(-1);
  2684.                }
  2685.                else
  2686.                {
  2687.                   _root.main.game.move(1);
  2688.                }
  2689.                if(!this._ie)
  2690.                {
  2691.                   this._ie = true;
  2692.                }
  2693.             }
  2694.             else if(this._ie)
  2695.             {
  2696.                _root.main.game._csx = 0;
  2697.             }
  2698.          }
  2699.          if(!_global._game_paused)
  2700.          {
  2701.             _root.anykey_count = _root.anykey_count + 1;
  2702.             _root.main.game.turn();
  2703.             if(_root.anykey_count > 140)
  2704.             {
  2705.                _root.show_tip(100);
  2706.             }
  2707.          }
  2708.       };
  2709.       this._char_xscale = _root.main.char._xscale;
  2710.    }
  2711.    function OpenWinnerWindow()
  2712.    {
  2713.       var _loc3_ = this.GetCountTilesOfType(CGame.TILES_ALL_MONSTERS,this._lvls);
  2714.       var _loc4_ = this.GetCountTilesOfType(CGame.TILES_ALL_BONUSES,this._lvls);
  2715.       CGame._level_total_time += getTimer() - this._level_start_time;
  2716.       _root.show_win_menu(this._current_map,this._scores,this._char_lives,this._stars_collecled,CGame._total_monsters_count,CGame._total_monsters_count - _loc3_,CGame._total_bonuses_count,CGame._total_bonuses_count - _loc4_,CGame._level_total_time);
  2717.    }
  2718.    function lose_game(reason_id)
  2719.    {
  2720.       CGame._level_total_time += getTimer() - this._level_start_time;
  2721.       this._char_lives = this._char_lives - 1;
  2722.       _global._game_paused = true;
  2723.       _root.main.tiles_scr.unloadMovie();
  2724.       _root.show_lose_menu(this._current_map,this._scores,reason_id,this._char_lives,this._checkpoint_x,this._checkpoint_y,this._lvls,this._diams);
  2725.    }
  2726.    function UpdateWaterLevel()
  2727.    {
  2728.       var _loc3_ = this._game_height + this._map_y - this.waterlevel_tiley;
  2729.       if(_loc3_ < 0)
  2730.       {
  2731.          _loc3_ = 0;
  2732.       }
  2733.       _root.main.mcWater._y = _loc3_;
  2734.    }
  2735. }
  2736.